Markdown tables in Plone 5.2

I have been using markdown tables in Plone.

Now, I tried to use markdown tables in Plone 5.2, but I can not get it to work.

| tab 1 | tab 2 |
| :-- | : -- |
| nr 1 | nr 2 |

I can not remember if I did something special earlier… or is this supposed to work in Plone 5.2 ?

Whitespace after second colon...

Sorry,

That is not in the 'real code'.
I have the same table on another site and on stackedit

I also tested here:
http://demo.plone.org/en/table

I think this is a bug. I can not get ANY Plone 5.2 setup to work with markdown. I will try to find out 'when it happened'.

If anyone has it working, please let me know.

In Plone 5.2.2 there is a new control panel for markdown.

If you add

markdown.extensions.tables

tables will work.

As a bonus, different syntaxes that did not work before can be used.

So both:

| 1 | 2  | 3  |
| :-- | :-- | :-- |
| one | two | four |

And

First Header  | Second Header
------------- | -------------
Content Cell  | Content Cell

Works.

UPDATE: The last synax is a big bonus, because that is what I get if I use Pandoc to convert word files to markdown.

1 Like

Plone is using Python Markdown, so you need to ensure the plugins you want to include are installed: https://python-markdown.github.io/extensions/

That is currently also the main problem for integrating a good markdown editor to be used within Plone. Because the editor extensions need to match the ones available for Python Markdown. Unless we skip portal transforms and write the generated markup directly to the output for a RichText field, and raw contains the raw markdown.

I made a markdown editor some years ago, and I would say that python markdown is very nice. I managed to do much more than js markdown (etc).

It is mostly used by myself, so I ended up with some workarounds that are not perfect, but as a UI it is very good ( I think). It has live preview (updated when you hit enter) and saves to a rich text field (so it might use more resources than necessary).

I could not get the add-on to work with 5.2 (due to markdown extensions not working properly), but with the update to 5.2.2 it should work again.

PS: I dont think anyone else (than me) has been using it so there are there might be some requirements (mathjax / font-awesome etc) that are not set as required.

Looks like all the (official https://python-markdown.github.io/extensions/ ) extensions work, except markdown.extensions.legacy_em which breaks the site.

I did a test with 'unofficial plugins' and added https://github.com/oleks-k/cell_row_span (to src and buildout)

Then I added cell_row_span to the control panel (note: only the name (not prefix with extension as said some places (on the web)).

Then I add the following table:

| Column 1                | Col 2 | Big row span   |
|:-----------------------:|-------| -------------- |
| r1_c1 spans two cols           || One large cell |
| r2_c1 spans two rows    | r2_c2 |                |
|_^                      _| r3_c2 |                |
|    Last line           | r4_c2 |_              _|

And it renders as:

UPDATE: I did a test with the (unofficial) superscript extension and it works too.

One thing I noticed: If you ONLY add this extension to the control panel, everything breaks. You can't even get back to the control panel.
So be sure to keep some some of the other extensions ( for example markdown.extensions.nl2br or markdown.extensions.extra)

Nice!

What is the error message you get?

I can only give you the error I get in the browser (at the moment).

It is this

Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 162, in transaction_pubevents
  Module ZPublisher.WSGIPublisher, line 359, in publish_module
  Module ZPublisher.WSGIPublisher, line 262, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module ZPublisher.WSGIPublisher, line 63, in call_object
  Module zope.browserpage.simpleviewclass, line 41, in __call__
  Module Products.Five.browser.pagetemplatefile, line 126, in __call__
  Module Products.Five.browser.pagetemplatefile, line 61, in __call__
  Module zope.pagetemplate.pagetemplate, line 135, in pt_render
  Module Products.PageTemplates.engine, line 367, in __call__
  Module z3c.pt.pagetemplate, line 176, in render
  Module chameleon.zpt.template, line 307, in render
  Module chameleon.template, line 214, in render
  Module chameleon.template, line 192, in render
  Module d07cff75d26951d0443aa37105aff59d, line 288, in render
  Module f9dd5ff64660d9c751f07c736469d52b, line 1255, in render_master
  Module f9dd5ff64660d9c751f07c736469d52b, line 393, in render_content
  Module d07cff75d26951d0443aa37105aff59d, line 273, in __fill_content_core
  Module d07cff75d26951d0443aa37105aff59d, line 158, in render_content_core
  Module zope.tales.pythonexpr, line 73, in __call__
   - __traceback_info__: (context.text.output_relative_to(view.context))
  Module <string>, line 1, in <module>
  Module plone.app.textfield.value, line 122, in output_relative_to
  Module plone.app.textfield.transform, line 92, in __call__
TransformError: Error during transformation

 - Expression: "python:context.text.output_relative_to(view.context)"
 - Filename:   ... egg/plone/app/contenttypes/browser/templates/document.pt
 - Location:   (line 15: col 29)
 - Source:     ... ucture python:context.text.output_relative_to(view.context)"
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 - Expression: "provider:plone.abovecontentbody"
 - Filename:   ... egg/Products/CMFPlone/browser/templates/main_template.pt
 - Location:   (line 94: col 70)
 - Source:     ... 
                                     ^
 - Expression: "context/main_template/macros/master"
 - Filename:   ... egg/plone/app/contenttypes/browser/templates/document.pt
 - Location:   (line 6: col 21)
 - Source:     ... etal:use-macro="context/main_template/macros/master"
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 - Arguments:  repeat: <Products.PageTemplates.engine.RepeatDictWrapper object at 0x7f40a40460f0>
               template: <Products.Five.browser.pagetemplatefile.ViewPageTemplateFile object at 0x7f409d4a65d0>
               views: <Products.Five.browser.pagetemplatefile.ViewMapper object at 0x7f409d412fd0>
               request: <WSGIRequest, URL=http://myserver:8052/Plone/dasfsdf/document_view>
               args: ()
               here: <Document at /Plone/dasfsdf>
               user: <PropertiedUser 'admin'>
               nothing: None
               translate: <function translate at 0x7f409d53e758>
               container: <Document at /Plone/dasfsdf>
               root: <Application at >
               modules: <Products.PageTemplates.ZRPythonExpr._SecureModuleImporter object at 0x7f40a9c21490>
               traverse_subpath: []
               default: <DEFAULT>
               loop: {}
               context: <Document at /Plone/dasfsdf>
               view: <Products.Five.browser.metaconfigure.SimpleViewClass from /home/medialog/vol2/instance8052/buildout-cache/eggs/plone.app.contenttypes-2.1.10-py2.7.egg/plone/app/contenttypes/browser/templates/document.pt object at 0x7f409d412e50>
               target_language: None
               macroname: u'master'
               options: {}
               attrs: {}

UPDATE: I noticed that if you add two newlines to the control panel you get the error, too

Since it is a bit confusing to set CSS classes to tables (and images) , I have been using this approach:

!!! cardtable ""
    |  One  | Two  |  four |
    |  :--  | :--  |  :--  |  
    |   a   |   b  |   c   |  

Then I can use the class for stackable ( and you get this: http://www.marfag.no/k38/kap-1, resize window )