[PYTHON] I really want to use GitHub Flavored Markdown (GFM) with Pelican!

I think I wrote something similar before. The plain Markdown is a little tight, isn't it? So I'll bring Pelican's Markdown closer to GFM. There is almost no difference.

It's Pelican, or the general story when using Python's Markdown library.

Conclusion

Install the following packages.

$ pip install mdx_linkify
$ pip install mdx_del_ins

Add the following to pelicanconf.py.

MD_EXTENSIONS = ['linkify', 'del_ins', 'fenced_code', 'codehilite(css_class=highlight)', 'tables']

That's it.

Goodbye here except for those who want to take a closer look.

Underscore in words

Ordinary Markdown is sad when there are multiple Ansco (_) in a word.

wow_great_stuff is like wow great </ em> stuff.

Some people may find this funky and good, but usually I don't like it. So first try not to do this.

If you think, Markdown in Python already has this feature. I'm glad I didn't do anything!

Congratulations!

goodbye!

URL automatic link

Hello!

You do this when you put a link.

[http://example.com](http://example.com)

Is this all right? Is the front one rounder? That? It's a pain to get confused soon. It looks like it's crazy. After all, I would like you to be careful and give consideration to automatic linking. I'm paying for this. I didn't pay.

Unfortunately, this is not possible with standard features alone. You can write your own extensions with regular expressions, but There is a good third-party extension called ** mdx_linkify **, so let's use it.

If you install it stylishly like this with pip,

$ pip install mdx_linkify

Write this in pelicanconf.py:

MD_EXTENSIONS = ['linkify']

Strikethrough

In GFM

~~Black history~~

By doing so, you can strike through ~~ Black History ~~ like this. Like this ... that? Hasn't it disappeared? My black history hasn't disappeared, right? Apparently it doesn't work with Markdown here either.

Midnight sun, jet-black darkness. Yes, I am a fallen angel. Look at your profile in the seat next to you. Huhuhu, you don't know the true me yet. </ del>

Hmm, it's dangerous.

Well, unfortunately this is not possible with standard features alone. Use the extension ** mdx_del_ins **.

$ pip install mdx_del_ins

pelicanconf.py looks like this.

MD_EXTENSIONS = ['linkify', 'del_ins']

Code block

Markdown uses indentation to represent code blocks, but GFM's three backticks are no longer the de facto momentum.

Here's an example:

```
function test() {
  console.log("notice the blank line before this function?");
}
```

It uses the standard built-in extension ** Fenced Code Blocks **.

pelicanconf.py will be enriched little by little.

MD_EXTENSIONS = ['linkify', 'del_ins', 'fenced_code']

Syntax highlighting

The program has nothing to do with an ignorant person like me who doesn't know anything about it, There seems to be a function called syntax highlighting. I'm stupid, I don't know what to use it for, but it seems that I can do this.

```ruby
require 'redcarpet'
markdown = Redcarpet.new("Hello World!")
puts markdown.to_html
```
require 'redcarpet'
markdown = Redcarpet.new("Hello World!")
puts markdown.to_html

Shouldn't we just silently add ** CodeHilite **!

MD_EXTENSIONS = ['linkify', 'del_ins', 'fenced_code', 'codehilite(css_class=highlight)']

table

By writing like this, the table will be hung.

 item         | expenses
------------- | -------------
TENGA         | 606
TENGA HARD    | 655
item expenses
TENGA 606
TENGA HARD 655

** Tables ** in the direction of addition.

MD_EXTENSIONS = ['linkify', 'del_ins', 'fenced_code', 'codehilite(css_class=highlight)', 'tables']

Summary

With the settings up to this point, you can use it in the same way as GFM! By the way, Pelican has codehilite and extra enabled as default extensions.

The reason why I specified codehilite with (css_class = highlight) was to avoid CSS not working effectively due to the difference between the default specification and the class.

By the way, extra is not specified in this example, but extra has other useful functions. The MD_EXTENSIONS is overwritten rather than added, thus disabling the extra feature. If you want extra functionality, add it.

Click here for details. http://pythonhosted.org/Markdown/extensions/

Recommended Posts

I really want to use GitHub Flavored Markdown (GFM) with Pelican!
I want to use MATLAB feval with python
I want to use Temporary Directory with Python2
I don't want to use -inf with np.log
I want to use ip vrf with SONiC
I want to use R functions easily with ipython notebook
[Python] I want to use the -h option with argparse
I want to use a virtual environment with jupyter notebook!
I want to do ○○ with Pandas
I want to debug with Python
Markdown output with Django
How to install Pelican blog
Added Theme to Pelican Blog
Blogging with Pelican on Windows
Use Github-Flavored-Markdown on your Pelican blog
Use markdown with jupyter notebook (with shortcut)
I really want to use GitHub Flavored Markdown (GFM) with Pelican!
[Python] Automate Pelican builds with Travis CI
I want to blog with Jupyter Notebook
I want to use a wildcard that I want to shell with Python remove
I want to detect objects with OpenCV
I want to blog with Jupyter Notebook
I want to use jar from python
I want to use Linux on mac
I want to pip install with PythonAnywhere
I want to analyze logs with Python
I want to play with aws with python
I want to use IPython Qt Console
I really wanted to copy with selenium
I tried to use lightGBM, xgboost with Boruta
I want to analyze songs with Spotify API 2
I want to mock datetime.datetime.now () even with pytest!
I want to display multiple images with matplotlib.
I want to knock 100 data sciences with Colaboratory
I want to make a game with Python
I want to be an OREMO with setParam!
I want to use ceres solver from python
#Unresolved I want to compile gobject-introspection with Python3
I want to solve APG4b with Python (Chapter 2)
I want to start over with Django's Migrate
I want to write to a file with Python
I want to use the activation function Mish
I want to use mkl with numpy and scipy under pyenv + poetry environment
I want to convert an image to WebP with lollipop
[Python] I want to add a static directory with Flask [I want to use something other than static]
[Python] I want to use only index when looping a list with a for statement
I want to detect unauthorized login to facebook with Jubatus (1)
I want to transition with a button in flask
I want to use self in Backpropagation (tf.custom_gradient) (tensorflow)
I want to handle optimization with python and cplex
I want to inherit to the back with python dataclass
I want to work with a robot in python.
I want to split a character string with hiragana
I want to AWS Lambda with Python on Mac!
[TensorFlow] I want to process windows with Ragged Tensor
I want to use OpenJDK 11 on Ubuntu Linux 18.04 LTS / 18.10
[ML Ops] I want to do multi-project with Python
I want to use the R dataset in python
I want to run a quantum computer with Python
I want to bind a local variable with lambda
I know? Data analysis using Python or things you want to use when you want with numpy
I really want to see my deposit balance in Python-Visualize cash stock flow with seaborn
Solution when you want to use cv_bridge with python3 (virtualenv)
I want to be able to analyze data with Python (Part 3)
I want to use the latest gcc without sudo privileges! !!
I want to remove Python's Unresolved Import Warning with vsCode
I want to specify another version of Python with pyvenv
I want to be able to analyze data with Python (Part 1)
I want to make a blog editor with django admin