From ad73cf6b36beae5d4b621af98680df3d7bf7ca1b Mon Sep 17 00:00:00 2001 From: trendschau Date: Mon, 18 May 2020 07:26:22 +0200 Subject: [PATCH 1/2] Version 1.3.7 wrap table in div --- system/Extensions/ParsedownExtension.php | 385 ++++++++++++++--------- 1 file changed, 230 insertions(+), 155 deletions(-) diff --git a/system/Extensions/ParsedownExtension.php b/system/Extensions/ParsedownExtension.php index de5ab2d..fafe83e 100644 --- a/system/Extensions/ParsedownExtension.php +++ b/system/Extensions/ParsedownExtension.php @@ -6,9 +6,9 @@ use \URLify; class ParsedownExtension extends \ParsedownExtra { - function __construct($showAnchor = NULL) + function __construct($showAnchor = NULL) { - parent::__construct(); + parent::__construct(); # show anchor next to headline? $this->showAnchor = $showAnchor; @@ -27,30 +27,30 @@ class ParsedownExtension extends \ParsedownExtra $this->visualMode = false; - # identify Table Of contents after footnotes and links + # identify Table Of contents after footnotes and links array_unshift($this->BlockTypes['['], 'TableOfContents'); } - + public function setVisualMode() { $this->visualMode = true; } - public function text($text, $relurl = null) - { + public function text($text, $relurl = null) + { $this->relurl = $relurl ? $relurl : ''; $Elements = $this->textElements($text); - - return $Elements; - } - - public function markup($Elements, $relurl) - { + + return $Elements; + } + + public function markup($Elements, $relurl) + { - # make relurl available for other functions - $this->relurl = $relurl; - + # make relurl available for other functions + $this->relurl = $relurl; + # convert to markup $markup = $this->elements($Elements); @@ -60,14 +60,14 @@ class ParsedownExtension extends \ParsedownExtra # merge consecutive dl elements $markup = preg_replace('/<\/dl>\s+
\s+/', '', $markup); - # create table of contents + # create table of contents if(isset($this->DefinitionData['TableOfContents'])) { - $TOC = $this->buildTOC($this->headlines); - - $markup = preg_replace('%(]*>\[TOC\]

)%i', $TOC, $markup); + $TOC = $this->buildTOC($this->headlines); + + $markup = preg_replace('%(]*>\[TOC\]

)%i', $TOC, $markup); } - + # add footnotes if (isset($this->DefinitionData['Footnote'])) { @@ -75,8 +75,8 @@ class ParsedownExtension extends \ParsedownExtra $markup .= "\n" . $this->element($Element); } - - return $markup; + + return $markup; } @@ -188,6 +188,81 @@ class ParsedownExtension extends \ParsedownExtra return $block; } + protected function blockTable($Line, array $Block = null) + { + + $Block = parent::blockTable($Line, $Block); + + if($Block) + { + $table = $Block['element']; + + $Block['element'] = [ + 'name' => 'div', + 'element' => $table, + 'attributes' => [ + 'class' => "tm-table", + ], + ]; + } + + return $Block; + } + + protected function blockTableContinue($Line, array $Block) + { + if (isset($Block['interrupted'])) + { + return; + } + + if (count($Block['alignments']) === 1 or $Line['text'][0] === '|' or strpos($Line['text'], '|')) + { + $Elements = array(); + + $row = $Line['text']; + + $row = trim($row); + $row = trim($row, '|'); + + preg_match_all('/(?:(\\\\[|])|[^|`]|`[^`]++`|`)++/', $row, $matches); + + $cells = array_slice($matches[0], 0, count($Block['alignments'])); + + foreach ($cells as $index => $cell) + { + $cell = trim($cell); + + $Element = array( + 'name' => 'td', + 'handler' => array( + 'function' => 'lineElements', + 'argument' => $cell, + 'destination' => 'elements', + ) + ); + + if (isset($Block['alignments'][$index])) + { + $Element['attributes'] = array( + 'style' => 'text-align: ' . $Block['alignments'][$index] . ';', + ); + } + + $Elements []= $Element; + } + + $Element = array( + 'name' => 'tr', + 'elements' => $Elements, + ); + + $Block['element']['element']['elements'][1]['elements'] []= $Element; + + return $Block; + } + } + # Handle notice blocks # adopted from grav: https://github.com/getgrav/grav-plugin-markdown-notices/blob/develop/markdown-notices.php # and yellow / datenstrom: https://raw.githubusercontent.com/datenstrom/yellow-extensions/master/features/markdown/markdownx.php @@ -215,7 +290,7 @@ class ParsedownExtension extends \ParsedownExtra return $Block; } } - + # Handle notice blocks over multiple lines # adopted from grav: https://github.com/getgrav/grav-plugin-markdown-notices/blob/develop/markdown-notices.php # and yellow / datenstrom: https://raw.githubusercontent.com/datenstrom/yellow-extensions/master/features/markdown/markdownx.php @@ -242,14 +317,14 @@ class ParsedownExtension extends \ParsedownExtra { if ($line['text'] == '[TOC]') { - $this->DefinitionData['TableOfContents'] = true; + $this->DefinitionData['TableOfContents'] = true; } } # Header - - public $headlines = array(); - + + public $headlines = array(); + protected function blockHeader($Line) { if (isset($Line['text'][1])) @@ -262,7 +337,7 @@ class ParsedownExtension extends \ParsedownExtra } $text = trim($Line['text'], '#'); - $headline = URLify::filter($Line['text']); + $headline = URLify::filter($Line['text']); if ($this->strictMode and isset($text[0]) and $text[0] !== ' ') { @@ -299,49 +374,49 @@ class ParsedownExtension extends \ParsedownExtra ); } - $this->headlines[] = array('level' => $level, 'name' => $Block['element']['name'], 'attribute' => $Block['element']['attributes']['id'], 'text' => $text); + $this->headlines[] = array('level' => $level, 'name' => $Block['element']['name'], 'attribute' => $Block['element']['attributes']['id'], 'text' => $text); return $Block; } } - + # build the markup for table of contents - public function buildTOC($headlines) - { - $markup = '
    '; - - foreach($headlines as $key => $headline) - { - $thisLevel = $headline['level']; - $prevLevel = $key > 0 ? $headlines[$key-1]['level'] : 1; - $nextLevel = isset($headlines[$key+1]) ? $headlines[$key+1]['level'] : 0; - - if($thisLevel > $prevLevel) - { - $markup .= '
      '; - } - - $markup .= '
    • ' . $headline['text'] . ''; - - if($thisLevel == $nextLevel) - { - $markup .= '
    • '; - } - elseif($thisLevel > $nextLevel) - { - while($thisLevel > $nextLevel) - { - $markup .= '
    '; - $thisLevel--; - } - } - } - - $markup .= '
'; - - return $markup; - } + public function buildTOC($headlines) + { + $markup = '
    '; + + foreach($headlines as $key => $headline) + { + $thisLevel = $headline['level']; + $prevLevel = $key > 0 ? $headlines[$key-1]['level'] : 1; + $nextLevel = isset($headlines[$key+1]) ? $headlines[$key+1]['level'] : 0; + + if($thisLevel > $prevLevel) + { + $markup .= '
      '; + } + + $markup .= '
    • ' . $headline['text'] . ''; + + if($thisLevel == $nextLevel) + { + $markup .= '
    • '; + } + elseif($thisLevel > $nextLevel) + { + while($thisLevel > $nextLevel) + { + $markup .= '
    '; + $thisLevel--; + } + } + } + + $markup .= '
'; + + return $markup; + } # # Footnote Marker @@ -363,9 +438,9 @@ class ParsedownExtension extends \ParsedownExtra return $element; } - - public $footnoteCount = 0; - + + public $footnoteCount = 0; + public function buildFootnoteElement() { $Element = array( @@ -574,7 +649,7 @@ class ParsedownExtension extends \ParsedownExtra return $Block; } - # advanced attribute data, check parsedown extra plugin: https://github.com/tovic/parsedown-extra-plugin + # advanced attribute data, check parsedown extra plugin: https://github.com/tovic/parsedown-extra-plugin protected function parseAttributeData($text) { // Allow compact attributes ... @@ -629,28 +704,28 @@ class ParsedownExtension extends \ParsedownExtra protected $regexAttribute = '(?:[#.][-\w:\\\]+[ ]*|[-\w:\\\]+(?:=(?:["\'][^\n]*?["\']|[^\s]+)?)?[ ]*)'; - # turn markdown into an array of markdown blocks for typemill edit mode - function markdownToArrayBlocks($markdown) - { + # turn markdown into an array of markdown blocks for typemill edit mode + function markdownToArrayBlocks($markdown) + { # standardize line breaks $markdown = str_replace(array("\r\n", "\r"), "\n", $markdown); # remove surrounding line breaks $markdown = trim($markdown, "\n"); - # trim to maximum two linebreaks - + # trim to maximum two linebreaks + # split text into blocks $blocks = explode("\n\n", $markdown); - - # clean up code blocks - $cleanBlocks = array(); - - # holds the content of codeblocks - $codeBlock = ''; - - # flag if codeblock is on or off. - $codeBlockOn = false; + + # clean up code blocks + $cleanBlocks = array(); + + # holds the content of codeblocks + $codeBlock = ''; + + # flag if codeblock is on or off. + $codeBlockOn = false; # holds the content of a definition list $definitionList = ""; @@ -658,46 +733,46 @@ class ParsedownExtension extends \ParsedownExtra # flag if definition-list is on or off. $definitionListOn = false; - foreach($blocks as $block) - { - # remove empty lines - if (chop($block) === '') continue; - - # if the block starts with a fenced code - if(substr($block,0,2) == '``') - { - # and if we are in an open code-block - if($codeBlockOn) - { - # it must be the end of the codeblock, so add it to the codeblock - $block = $codeBlock . "\n" . $block; - - # reset codeblock-value and close the codeblock. - $codeBlock = ''; - $codeBlockOn = false; - } - else - { - # it must be the start of the codeblock. - $codeBlockOn = true; - } - } - if($codeBlockOn) - { - # if the codeblock is complete - if($this->isComplete($block)) - { - $block = $codeBlock . "\n" . $block; + foreach($blocks as $block) + { + # remove empty lines + if (chop($block) === '') continue; + + # if the block starts with a fenced code + if(substr($block,0,2) == '``') + { + # and if we are in an open code-block + if($codeBlockOn) + { + # it must be the end of the codeblock, so add it to the codeblock + $block = $codeBlock . "\n" . $block; + + # reset codeblock-value and close the codeblock. + $codeBlock = ''; + $codeBlockOn = false; + } + else + { + # it must be the start of the codeblock. + $codeBlockOn = true; + } + } + if($codeBlockOn) + { + # if the codeblock is complete + if($this->isComplete($block)) + { + $block = $codeBlock . "\n" . $block; - # reset codeblock-value and close the codeblock. - $codeBlock = ''; - $codeBlockOn = false; - } - else - { - $codeBlock .= "\n" . $block; - continue; - } + # reset codeblock-value and close the codeblock. + $codeBlock = ''; + $codeBlockOn = false; + } + else + { + $codeBlock .= "\n" . $block; + continue; + } } # handle definition lists @@ -715,37 +790,37 @@ class ParsedownExtension extends \ParsedownExtra $definitionListOn = false; } - $block = trim($block, "\n"); - - $cleanBlocks[] = $block; - } - return $cleanBlocks; - } - - public function arrayBlocksToMarkdown(array $arrayBlocks) - { - $markdown = ''; - - foreach($arrayBlocks as $block) - { - $markdown .= $block . "\n\n"; - } - - return $markdown; - } - - protected function isComplete($codeblock) - { - $lines = explode("\n", $codeblock); - if(count($lines) > 1) - { - $lastLine = array_pop($lines); - if(substr($lastLine,0,2) == '``') - { - return true; - } - return false; - } - return false; - } + $block = trim($block, "\n"); + + $cleanBlocks[] = $block; + } + return $cleanBlocks; + } + + public function arrayBlocksToMarkdown(array $arrayBlocks) + { + $markdown = ''; + + foreach($arrayBlocks as $block) + { + $markdown .= $block . "\n\n"; + } + + return $markdown; + } + + protected function isComplete($codeblock) + { + $lines = explode("\n", $codeblock); + if(count($lines) > 1) + { + $lastLine = array_pop($lines); + if(substr($lastLine,0,2) == '``') + { + return true; + } + return false; + } + return false; + } } \ No newline at end of file From 56b10df1dadf2ef857e031a681fd9bd03c41a101 Mon Sep 17 00:00:00 2001 From: trendschau Date: Tue, 19 May 2020 20:04:35 +0200 Subject: [PATCH 2/2] french --- readme.md | 49 ++++++++++++++++++------------- themes/typemill/languages/fr.yaml | 33 +++++++++++++++++++++ 2 files changed, 62 insertions(+), 20 deletions(-) create mode 100644 themes/typemill/languages/fr.yaml diff --git a/readme.md b/readme.md index 3b7d229..20f738a 100644 --- a/readme.md +++ b/readme.md @@ -6,23 +6,24 @@ TYPEMILL is a small flat file cms created for editors and writers. It provides a ## Features -* Creates a website based on markdown files. -* Provides an author-friendly visual markdown editor (work in progress, based on VUE.js). -* Provides a pure markdown editing mode. -* Markdown supports table of contents (TOC), tables, footnotes, abbreviations and definition lists. -* Create and sort pages with drag & drop in the navigation. -* Configure the system, the themes and the plugins in the dashboard. -* Create and manage users. -* Develop configurable plugins with the Symfony Event Dispatcher. -* Develop configurable themes with TWIG. -* Allows super easy backend and frontend forms with simple YAML-files. -* Ships with a fully responsive standard theme -* Ships with plugins for - * Search - * MathJax and KaTeX. - * Code highlighting. - * Matomo/Piwik and Google Analytics. - * Cookie Consent. +* Website with markdown-files. +* Flexible drag & drop navigation. +* Visual markdown editor (VUE.js) and raw markdown mode. +* Markdown extras with + * table of contents (TOC) + * tables + * footnotes + * abbreviations + * definition lists + * notices + * math (with plugin) + * figures with captions +* Media library with images and files. +* System configurations. +* User management. +* Flexible form management with YAML-files. +* Plugins (with symfony event dispatcher). +* Themes (with TWIG). ## Requirements @@ -77,10 +78,16 @@ TYPEMILL is published under MIT licence. Please check the licence of the include ## Contributors & Supporters -* [Severo Juliano](https://github.com/iusvar) did the internationalization i18n. +* [Severo Juliano](https://github.com/iusvar) manages the internationalization i18n. * [Eziquel Bruni](https://github.com/EzequielBruni) edits the typemill documentation. * [Ricky](https://github.com/rbertram90) developed the discard functionality. * [vodaris](https://www.vodaris.de) sponsored the development of the search plugin. +* Translations: + * Dutch: [svanlaere](https://github.com/svanlaere) + * French: [Olivier Crouzet]https://github.com/oliviercrouzet + * German: [trendschau](https://github.com/trendschau) + * Italian: [Severo Juliano](https://github.com/iusvar) + * Russian: [Hide-me](https://github.com/hide-me) ## How to Contribute @@ -90,10 +97,11 @@ You can check the [roadmap for Typemill](https://github.com/typemill/typemill/is Here are some contribution-ideas for non-coder: -* Find bugs and errors (open a new issue on github for it). +* Share typemill with social media. +* Write about typemill. * Improve the documentation. +* Find bugs and errors (open a new issue on github for it). * Describe some missing features and explain, why they are important for other users. -* Write a blog post about typemill. Some ideas for devs (please fork this repository make your changes and create a pull request): @@ -103,6 +111,7 @@ Some ideas for devs (please fork this repository make your changes and create a * An auto-update functionality for core system, plugins and themes is highly needed. * Improve the accessibility of html and css. * Implement user roles and rights with RBAC or ACL. +* Write autotests with Cypress. For hints, questions, problems and support, please open up a new issue on GitHub. diff --git a/themes/typemill/languages/fr.yaml b/themes/typemill/languages/fr.yaml new file mode 100644 index 0000000..f8a4e96 --- /dev/null +++ b/themes/typemill/languages/fr.yaml @@ -0,0 +1,33 @@ +# Français +ACTIVATE_SPECIAL_STARTPAGE_DESIGN: Activer le design spécial pour la page d'accueil +ADD_LABEL_FOR_START_BUTTON: Ajouter une étiquette pour le bouton de démarrage +ADD_NAME_FOR_CHAPTER: Ajouter des noms de chapitre +AUTHOR_INTRO: Étiquette de mention de l'auteur +CHAPTER: Chapitre +COUNT_CHAPTERS_IN_NAVIGATION?: Numéroter les chapitres dans la navigation ? +DIFFERENT_DESIGN_FOR_STARTPAGE: Design différent pour la page d'accueil +FACEBOOK: Facebook +GITHUB: GitHub +LABEL_FOR_CHAPTER: Étiquette de chapitre +LABEL_FOR_START_BUTTON: Étiquette pour le bouton Démarrer +LAST_MODIFIED_FORMAT: Format de la date de modification +LAST_MODIFIED: Dernière modification +LAST_MODIFIED_TEXT: Étiquette pour la date de modification +LAST_UPDATED: Dernière mise à jour +LINKEDIN: Linkedin +LINK_TO_GIT_REPOSITORY: Lien vers le dépôt git +LOGO_ON_STARTPAGE: Logo sur la page d'accueil +MAIL: Courriel +PLEASE_ADD_THE_BASE_URL_TO_THE_TEXT_REPOSITORY_E_G__ON_GITHUB_: Veuillez ajouter l'url de base pour le dépôt git (par ex. Github) +POSITION_OF_AUTHOR: Position de l'auteur +POSITION_OF_GIT_EDIT_LINK: Position du lien d'édition dans github +POSITION_OF_MODIFIED_TEXT: Position de la date de modification +POSITION_OF_SHARE_BUTTONS: Position des boutons de partage +SELECT_SHARE_BUTTONS: Sélection des boutons de partage +SHARE: Partager +SHOW_CHAPTER_NUMBERS: Afficher les numéros de chapitre +SHOW_LOGO_INSTEAD_OF_TITLE_ON_STARTPAGE: Afficher le logo au lieu du titre en page d'accueil +THE_STANDARD_THEME_FOR_TYPEMILL__RESPONSIVE__MINIMAL_AND_WITHOUT_ANY_DEPENDENCIES__IT_USES_THE_SYSTEM_FONTS_CALIBRI_AND_HELVETICA__NO_JAVASCRIPT_IS_USED_: 'Le thème standard pour Typemill. Responsive, minimal et sans aucune dépendances. Il emploie les polices système Calibri et Helvetica. Pas de Javascript utilisé.' +TWITTER: Twitter +WHATSAPP: WhatsApp +XING: Xing