Download the PHP package mistralys/markdown-viewer without Composer

On this page you can find all versions of the php package mistralys/markdown-viewer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package markdown-viewer

Markdown documentation viewer

PHP based viewer for Markdown files, to view them with fenced code highlighting and navigation.

It is designed to be used for viewing markdown-based documentation files, in a fire and forget way. The layout is based on Bootstrap 5, and does not need any additional configuration.

Requirements

Features

Installing

The package is made to be used as a dependency in a documentation project: Put it in a folder in a webserver, point it to some markdown files, and it will display them.

1) Create a folder in your webroot from which to serve the documentation. 2) Create a composer project there. 3) Require the package: composer require mistralys/markdown-viewer. 4) Create a PHP file (index.php) as endpoint for the documentation. 5) Paste the following code into the file 6) Edit the list of files you wish to view. 7) Point your browser to the file.

Adding single files

Single files can be added using addFile(). This allows specifying the name that the file will be listed under in the UI.

Adding folders

To add multiple files, use the addFolder() method:

By default, all files with the md extension will be added. A different extension can be specified using the third parameter:

NOTE: Adding files this way means you cannot specify file IDs (see "Consistent file permalinks"). Please double-check that this is okay in your use case.

Consistent file permalinks

By default, the viewer will create an ID for each file based on its absolute path on disk. This means that the ID will change if the file is moved at some point, or if the viewer is used on different systems. Sharing permalinks risks the links being broken at some point.

To avoid this issue, specify a unique file ID manually when adding single files:

The ID can be any string; the viewer uses it to create the hash that is used in the UI to identify the files. This way, permalinks will always stay consistent.

Dark mode

To turn on dark mode, simply use makeDarkMode():

Viewing the example

The bundled example is built exactly like the example above, and will display this README.md file. To get it running, follow these steps:

1) Clone the repository into a webserver's document root 2) Run composer install in the package folder to install the dependencies 3) Point your browser to the package folder's example.php file

Setting options

All options regarding the parsing of markdown files are handled by the DocsConfig class. You can optionally pass a configuration instance to the manager to customize settings:

Including external files

The include command

The {include-file} command allows you to import the content of external files into your documents. This is especially handy for code examples, as it allows you to maintain them separately from the main document.

If viewed through example.php, the following code sample is loaded dynamically, for example:

The command looks like this:

NOTE: It is easy to go overboard with includes. Keep in mind that Markdown files are meant to be read as-is. Splitting them up too much will make them unreadable without the UI. Use them where it makes sense, like for large code samples.

Setting allowed paths

Include commands are disallowed by default, as long as no include folders have been configured:

Paths in the {include-file} command are relative to the configured include paths. Multiple folders can be added, and all of them are searched. The first matching file name is then used.

Setting allowed extensions

By default, only md and txt files are allowed to be included. Additional extensions can easily be added:

Several extensions can also be added at once:

Restricting file sizes

To avoid including large files, only files up to 6Kb may be included by default. This can be adjusted with the configuration class:

Filtering include file contents

Filters allow the pre-processing of included files before they are rendered by the Markdown renderer. The whole content of the files can be filtered to prepare them for rendering.

Example filter class

This filter ensures that all occurrences of EXAMPLE in the text are formatted as bold text.

Adding filters

Adding filters is very easy. Simply add a filter instance to the configuration, it will automatically be applied.

Only filter specific files

By default, filters are applied to all files that match the filter's file extension(s). However, if the extension matches, the filter is only applied if the isValidFor() method returns true. This makes it possible to use the provided file and configuration information to decide whether to filter the content.

The following example limits the filtering to included files found in the folder /path/to/target/folder, or any of its subfolders.


All versions of markdown-viewer with dependencies

PHP Build Version
Package Version
Requires erusev/parsedown Version >=1.7.4
erusev/parsedown-extra Version >=0.8.1
twbs/bootstrap Version >=v5.3.0
components/jquery Version >=3.5.1
mistralys/application-utils Version >=2.3.4
mistralys/application-localization Version >=1.4.1
php Version >=7.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mistralys/markdown-viewer contains the following files

Loading the files please wait ....