Jump to content

How to use the built in markdown parser


bernhard
 Share

Recommended Posts

  • 8 months later...

@bernhard - Where does d() come from? In my ProcessWire 3.0.165 (production) I get:

$str = "| Entry |
| Foo |";
$md = $modules->get('TextformatterMarkdownExtra');
$md->format($str);
d($str);
// Fatal Error: Uncaught Error: Call to undefined function d()

// Same for:
d('foo');

 

Link to comment
Share on other sites

d() is the dumping feature of Tracy Debugger 🙂 

Use it in the tracy console code panel and you'll be a lot faster with such quick php snippet tests/creations 😉 

  • Thanks 1
Link to comment
Share on other sites

  • 5 months later...

This textformatter seems to work for really simple Markdown things like emphasis  and headers. But I get Trying to access array offset on value of type null errors if I do any of the following:

  • create an unordered list by beginning successive lines with `- `
  • feed it text that contains a bracket character (`[`) that’s not being used as part of a link
  • put a short string of `-` characters on a line of its own to generate a horizontal rule

Interestingly, if I try to create an unordered list by beginning successive lines with `• ` instead of `- ` (both are acceptable Markdown syntaxes), the attempt is just ignored: no formatting is done and no error occurs.

Also interestingly, ordered lists work as expected!

Are others encountering these problems? I really want to be able to parse Markdown. I’d love for extended things like footnotes and tables to be supported, but I’d settle for Gruber’s original bare-bone syntax.

Link to comment
Share on other sites

14 hours ago, ErikMH said:

But I get Trying to access array offset on value of type null errors if I do any of the following:

  • create an unordered list by beginning successive lines with `- `
  • feed it text that contains a bracket character (`[`) that’s not being used as part of a link
  • put a short string of `-` characters on a line of its own to generate a horizontal rule

It's working for me.

2021-07-19_160540.thumb.png.dd756c0c88d7f6ddd5418fcf7a9e87e6.png

I'm using PHP 7.3 so if you are using a newer version then it could be that the included Parsedown library needs an update. If you trace it back to being related to PHP version then please open a GitHub issue because TextformatterMarkdownExtra is a core module.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...