Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difference in CodeBlock class information between md and rst sources #4523

Open
Evidlo opened this issue Apr 4, 2018 · 2 comments
Open

Difference in CodeBlock class information between md and rst sources #4523

Evidlo opened this issue Apr 4, 2018 · 2 comments

Comments

@Evidlo
Copy link

Evidlo commented Apr 4, 2018

I have the following Markdown and ReST source files:

# hello world

    ```python
    def testing(foo):
        print('hi')
    ```
hello world
-----------

.. code:: python

   def testing(foo):
       print('hi')

I have written a simple Python filter that prints classes to a file.

#!/usr/bin/env python3

from pandocfilters import toJSONFilter

def log(foo):
    with open('/tmp/dump', 'w') as f:
        f.write(foo)


def my_filter(key, value, format_, meta):
    if format_ == 'latex' and key == 'CodeBlock':
        (ident, classes, attributes), contents = value
        log(str(classes))

if __name__ == '__main__':
    toJSONFilter(my_filter)

With the Markdown source, I get ['python'], but with the ReST source I get ['sourceCode', 'python']. Should these not be the same? This makes language detection problematic.

@mb21
Copy link
Collaborator

mb21 commented Apr 4, 2018

Good point, e.g. the markdown, gfm, docbook readers all render to CodeBlock ("",["python"] ... (using -t native). So this seems like an inconsistency in the rst reader.

@jgm
Copy link
Owner

jgm commented Apr 4, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants