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

Support md files #40

Open
meri-burgess opened this issue Dec 16, 2022 · 8 comments
Open

Support md files #40

meri-burgess opened this issue Dec 16, 2022 · 8 comments
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest help wanted Extra attention is needed

Comments

@meri-burgess
Copy link

Currently, emojis are only supported in .rst. It would be great to be able to use the tool for .md files as well

@Peque Peque added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers hacktoberfest labels Dec 17, 2022
@Peque
Copy link
Member

Peque commented Dec 17, 2022

Thanks for your suggestion @meri-burgess! 😊

Could you elaborate a bit more on your use case? I'm guessing you use an extension in Sphinx to support Markdown. If so, which one? Does it support variable substitutions like |release|, |version|?

@casperdcl
Copy link

In markdown, you can use eval-rst:

```{eval-rst}
|:white_check_mark:| hacky
```

to get:

✅ hacky

@jdillard
Copy link

I'm not positive, but it seems the extension only parses .rst:

self.parser = self.app.registry.create_source_parser(self.app, 'rst')

where as it should support everything in source_suffix?

@casperdcl
Copy link

casperdcl commented Sep 21, 2023

Yes and I suppose the .md syntax would be [:smile:] or [](:smile:)

@jdillard
Copy link

myst-parser automatically adds .md to source_suffx: https://github.com/executablebooks/MyST-Parser/blob/ebf989fdae10c68dfbd3dcdfec4b86259b810cd9/myst_parser/sphinx_ext/main.py#L34

The problem isn't the syntax to be parsed, its the suffix (extension) of the files to be parsed.

@casperdcl
Copy link

casperdcl commented Sep 21, 2023

yes I know, I was just commenting on what the future PR should probably support in terms of UX (in response to this) :)

@dannybeckett
Copy link

dannybeckett commented Feb 25, 2024

@Peque @casperdcl @jdillard

I am interested in trying to completely swap rst for md (I have no .rst files, only .md files).

I tried this:

apt-get update && apt-get install git -y
git clone https://github.com/sphinx-contrib/emojicodes.git ../emojicodes
sed -i "s/rst/md/" ../emojicodes/sphinxemoji/sphinxemoji.py
cat ../emojicodes/sphinxemoji/sphinxemoji.py
pip install build
python -m build ../emojicodes
pip install ../emojicodes/dist/*.whl

It successfully replaces rst with md + loads the extension in to Sphinx, but unfortunately still doesn't want to display emojis.

I am using the myst_parser extension to parse Markdown, which supports substitution.

In conf.py I have myst_enable_extensions = ['substitution']

In the .md file I have tried:

:white_check_mark:
[:white_check_mark:]
|:white_check_mark:|
{{:white_check_mark:}}
{{white_check_mark}}
{{"a" + "b"}}
```{eval-rst}
|:white_check_mark:|
```

Myst uses {{ .. }} as delimiters, but the delimiter is configurable.

The ones inside {{ .. }} in my list/code block above are replaced with blank strings, except "a" + "b" which successfully replaces to ab. The {eval-rst} still continues to show the emoji unexpectedly though.

Usually Myst expects you to feed it a list of substitutions in the conf.py or in the .md file.

Any help is much appreciated please!

See also: Stack Overflow question

Many thanks

@Peque
Copy link
Member

Peque commented Feb 26, 2024

@dannybeckett I haven't had the time to look at this, but I'd be happy to review and integrate a PR if someone is able to implement it. 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants