GithubHelp home page GithubHelp logo

leomoon-studios / parsedownplus Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 23 KB

ParsedownPlus is an extension of Parsedown that adds support for custom tags such as colored text, forced RTL/LTR direction, monospace fonts, and video embedding.

License: GNU General Public License v3.0

PHP 100.00%

parsedownplus's Introduction

ParsedownPlus

ParsedownPlus is an extension of Parsedown that adds support for custom tags such as colored text, forced RTL/LTR direction, monospace fonts, and video embedding for YouTube and Vimeo. These custom tags are not standard Markdown.

GitHub Repository

Installation

  1. Include the ParsedownPlus.php class in your project.
  2. (Optional) Create a config.php file in the same directory as ParsedownPlus.php to define custom colors and fonts. You can use the provided config-sample.php as a template.
<?php
// include parsedown libraries
require_once(BASE."libraries/parsedown-1.8.0-beta-6/Parsedown.php");
require_once(BASE."libraries/parsedown-extra-0.8.1/ParsedownExtra.php");
require_once(BASE."libraries/parsedown-extended-1.1.2-modified/ParsedownExtended.php");
require_once(BASE."libraries/parsedown-filter-0.0.1/ParsedownFilter.php");
require_once(BASE."libraries/parsedown-plus-0.0.5/ParsedownPlus.php");

// initialize markdown parser
$PARSER=new ParsedownPlus([
	'typographer' => true,
	'toc' => true,
	'sup' => true,
	'sub' => true
]);

$markdown = "YouTube video: [video src=\"https://www.youtube.com/watch?v=Ta_wxUvvO4c\"]

Vimeo video: [video src=\"https://vimeo.com/423640994\"]

[color=#ff0000]Red[/color], [color=#00FF00]Green[/color], [color=#0000FF]Blue[/color]

[rtl]Forced RTL text.[/rtl]

[mono]Forced monospaced text.[/mono]

;
$html = $PARSER->text($markdown);
echo $html;

Configuration (optional)

config-sample.php

<?php

return [
    // Define a custom monospace font
    'fonts' => [
        'monospace' => 'Courier New, monospace',
    ],
    // Add predefined colors
    'colors' => [
        'customred' => '#8D021F',
        // Add more colors as needed
    ]
];

Examples

YouTube Embedding

[video src="https://www.youtube.com/watch?v=Ta_wxUvvO4c"]

Vimeo Embedding

[video src="https://vimeo.com/423640994"]

Colored Text

[color=#ff0000]Red[/color], [color=#00FF00]Green[/color], [color=#0000FF]Blue[/color]

Predefined colors can be used like this:

Predefined colors: [color=customred]predefined red[/color].

Forced RTL/LTR

[rtl]Forced RTL example.[/rtl]

Monospace Font

[mono]example[/mono]

Collapsible section

+++ Collapsible title (optional)
This is the content for the collapsible section. If title is not defined, it will default to: `Click to expand`
+++

License

ParsedownPlus is licensed under the GPLv3 License. See the LICENSE file for more details.

Contributions

Contributions are welcome! If you have suggestions, bug reports, or feature requests, please open an issue or submit a pull request on the repository. Make sure to follow the project's code of conduct and contribution guidelines. Thank you for helping improve ParsedownPlus!

parsedownplus's People

Contributors

leomoon avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.