Fix rendering MD files of images by adding a css

This commit is contained in:
Laurent Destailleur 2017-12-16 12:11:46 +01:00
parent 9cdf322bfb
commit 394eeb3cd9
6 changed files with 70 additions and 19 deletions

View File

@ -134,6 +134,27 @@ Change also file Luracast/Restler/explorer/index.html
PARSEDOWN PARSEDOWN
--------- ---------
* Add support of css by adding in Parsedown.php:
// @CHANGE LDR
'class' => $Link['element']['attributes']['class']
...
// @CHANGE LDR
if (preg_match('/{([^}]+)}/', $remainder, $matches2))
{
$Element['attributes']['class'] = $matches2[1];
$remainder = preg_replace('/{'.preg_quote($matches2[1],'/').'}/', '', $remainder);
}
// @CHANGE LDR
//$markup .= $this->{$Element['handler']}($Element['text']);
$markup .= preg_replace('/>{[^}]+}/', '>', $this->{$Element['handler']}($Element['text']));
* Fix to avoid fatal error when mb_strlen not available: * Fix to avoid fatal error when mb_strlen not available:
// @CHANGE LDR Fix when mb_strlen is not available // @CHANGE LDR Fix when mb_strlen is not available

View File

@ -641,6 +641,7 @@ class DolibarrModules // Can not be abstract, because we need to insta
if ((float) DOL_VERSION >= 6.0) if ((float) DOL_VERSION >= 6.0)
{ {
@include_once DOL_DOCUMENT_ROOT.'/core/lib/parsemd.lib.php'; @include_once DOL_DOCUMENT_ROOT.'/core/lib/parsemd.lib.php';
$content = dolMd2Html($content, 'parsedown', $content = dolMd2Html($content, 'parsedown',
array( array(
'doc/'=>dol_buildpath(strtolower($this->name).'/doc/', 1), 'doc/'=>dol_buildpath(strtolower($this->name).'/doc/', 1),

View File

@ -1180,7 +1180,9 @@ class Parsedown
'name' => 'img', 'name' => 'img',
'attributes' => array( 'attributes' => array(
'src' => $Link['element']['attributes']['href'], 'src' => $Link['element']['attributes']['href'],
'alt' => $Link['element']['text'], 'alt' => $Link['element']['text'],
// @CHANGE LDR
'class' => $Link['element']['attributes']['class']
), ),
), ),
); );
@ -1231,6 +1233,13 @@ class Parsedown
} }
$extent += strlen($matches[0]); $extent += strlen($matches[0]);
// @CHANGE LDR
if (preg_match('/{([^}]+)}/', $remainder, $matches2))
{
$Element['attributes']['class'] = $matches2[1];
$remainder = preg_replace('/{'.preg_quote($matches2[1],'/').'}/', '', $remainder);
}
} }
else else
{ {
@ -1426,7 +1435,9 @@ class Parsedown
if (isset($Element['handler'])) if (isset($Element['handler']))
{ {
$markup .= $this->{$Element['handler']}($Element['text']); // @CHANGE LDR
//$markup .= $this->{$Element['handler']}($Element['text']);
$markup .= preg_replace('/>{[^}]+}/', '>', $this->{$Element['handler']}($Element['text']));
} }
else else
{ {

View File

@ -3,6 +3,10 @@
## Features ## Features
Description... Description...
<!--
![Screenshot mymodule](img/screenshot_mymodule.png?raw=true "MyModule"){imgmd}
-->
Other modules are available on <a href="https://www.dolistore.com" target="_new">Dolistore.com</a>. Other modules are available on <a href="https://www.dolistore.com" target="_new">Dolistore.com</a>.
@ -25,44 +29,44 @@ There is a [Transifex project](https://transifex.com/projects/p/dolibarr-module-
Install Install
------- -------
### Manually ### From the ZIP file and GUI interface
- Make sure Dolibarr is already installed and configured on your workstation or development server. - If you get the module in a zip file (like when downloading it from the market place [Dolistore](https://www.dolistore.com)), go into
menu ```Home - Setup - Modules - Deploy external module``` and upload the zip file.
- In your Dolibarr installation directory, edit the ```htdocs/conf/conf.php``` file
- Find the following lines: Note: If this screen tell you there is no custom directory, check your setup is correct:
- In your Dolibarr installation directory, edit the ```htdocs/conf/conf.php``` file and check that following lines are not commented:
```php ```php
//$dolibarr_main_url_root_alt ... //$dolibarr_main_url_root_alt ...
//$dolibarr_main_document_root_alt ... //$dolibarr_main_document_root_alt ...
``` ```
- And uncomment these lines (delete the leading ```//```) and assign a sensible value according to your Dolibarr installation - Uncomment them if necessary (delete the leading ```//```) and assign a sensible value according to your Dolibarr installation
For example : For example :
- UNIX: - UNIX:
```php ```php
$dolibarr_main_url_root = 'http://localhost/Dolibarr/htdocs';
$dolibarr_main_document_root = '/var/www/Dolibarr/htdocs';
$dolibarr_main_url_root_alt = '/custom'; $dolibarr_main_url_root_alt = '/custom';
$dolibarr_main_document_root_alt = '/var/www/Dolibarr/htdocs/custom'; $dolibarr_main_document_root_alt = '/var/www/Dolibarr/htdocs/custom';
``` ```
- Windows: - Windows:
```php ```php
$dolibarr_main_url_root = 'http://localhost/Dolibarr/htdocs';
$dolibarr_main_document_root = 'C:/My Web Sites/Dolibarr/htdocs';
$dolibarr_main_url_root_alt = '/custom'; $dolibarr_main_url_root_alt = '/custom';
$dolibarr_main_document_root_alt = 'C:/My Web Sites/Dolibarr/htdocs/custom'; $dolibarr_main_document_root_alt = 'C:/My Web Sites/Dolibarr/htdocs/custom';
``` ```
For more information about the ```conf.php``` file take a look at the conf.php.example file. ### From a GIT repository
- Clone the repository in ```$dolibarr_main_document_root_alt/mymodule``` - Clone the repository in ```$dolibarr_main_document_root_alt/mymodule```
```sh ```sh
git clone git@github.com:Dolibarr/dolibarr-module-template.git mymodule cd ....../custom
git clone git@github.com:gitlogin/mymodule.git mymodule
``` ```
### <a name="final_steps"></a>Final steps ### <a name="final_steps"></a>Final steps
@ -75,11 +79,6 @@ From your browser:
## Publishing the module
The de-facto standard for publishing and marketing modules for Dolibarr is the [Dolistore](https://www.dolistore.com).
Templates for required images and texts are [provided](dev/dolistore).
Check the dedicated [README](dev/dolistore/README.md) for more informations.
--> -->

View File

@ -4575,6 +4575,15 @@ dl.dropdown {
} }
/* ============================================================================== */
/* Mardown rendering */
/* ============================================================================== */
.imgmd {
width: 90%;
}
/* ============================================================================== */ /* ============================================================================== */
/* JMobile */ /* JMobile */
/* ============================================================================== */ /* ============================================================================== */

View File

@ -4558,6 +4558,16 @@ dl.dropdown {
} }
/* ============================================================================== */
/* Mardown rendering */
/* ============================================================================== */
.imgmd {
width: 90%;
}
/* ============================================================================== */ /* ============================================================================== */
/* JMobile */ /* JMobile */
/* ============================================================================== */ /* ============================================================================== */