Extensions
extensions 導入の備忘録。
Material Extensions#
materialテーマ標準のextensions。
Admonition#
mkdocs.yml
:
markdown_extensions:
- admonition
Types:
Note
Qualifiers: note
, seealso
Abstract
Qualifiers: abstract
, summary
, tldr
Info
Qualifiers: info
, todo
Tip
Qualifiers: tip
, hint
, important
Success
Qualifiers: success
, check
, done
Question
Qualifiers: question
, help
, faq
Warning
Qualifiers: warning
, caution
, attention
Failure
Qualifiers: failure
, fail
, missing
Danger
Qualifiers: danger
, error
Bug
Qualifiers: bug
Example
Qualifiers: example
Quote
Qualifiers: quote
, cite
Changing the title:
おすきなタイトル
に変更できます。
!!! note "おすきなタイトル"
に変更できます。
Removing the title:
たいとるなし
!!! note ""
たいとるなし
Collapsible blocks:
Click me!!
本文を収納・展開できます
??? note "Click me!!"
本文を収納・展開できます
CodeHilite#
mkdocs.yml
:
markdown_extensions:
- codehilite
行番号表示:
1 2 3 4 5 6 |
|
``` python linenums="1"
""" Bubble sort """
def bubble_sort(items):
for i in range(len(items)):
for j in range(len(items) - 1 - i):
if items[j] > items[j + 1]:
items[j], items[j + 1] = items[j + 1], items[j]
```
特定の行をハイライトする;
\documentclass{jsarticle}
\begin{document}
\begin{align}
H \psi = E \psi
\end{align}
\end{document}
```tex hl_lines="1-2 6"
\documentclass{jsarticle}
\begin{document}
\begin{align}
H \psi = E \psi
\end{align}
\end{document}
```
PyMdown Extensions#
絵文字 Emoji#
installation:
pip install pymdown-extensions
pip install mkdocs-material-extensions
mkdocs.yml
:
markdown_extensions:
- pymdownx.emoji:
emoji_index: !!python/name:materialx.emoji.twemoji
emoji_generator: !!python/name:materialx.emoji.to_svg
examples:
:smile:
:hankey: :poop: :shit:
:+1:
SmartSymbols#
mkdocs.yml
:
markdown_extensions:
- pymdownx.smartsymbols:
fractions: false #? does not work
ordinal_numbers: false
Markdown | Result |
---|---|
(tm) |
™ |
(c) |
© |
(r) |
® |
c/o |
℅ |
+/- |
± |
--> |
→ |
<-- |
← |
<--> |
↔ |
=/= |
≠ |
1/4, etc. |
¼, etc. |
1st 2nd etc. |
1st 2nd etc. |
Keys#
mkdocs.yml
:
markdown_extensions:
- pymdownx.keys
Markdown | Result |
---|---|
++cmd+comma++ |
Cmd+, |
++a+b+c+space++ |
A+B+C+Space |
InlineHilite#
markdown_extensions:
- pymdownx.inlinehilite
Markdown | Result |
---|---|
`\usepackage{amsmath}` |
\usepackage{amsmath} |
`:::tex \usepackage{amsmath}` |
\usepackage{amsmath} |
`#!tex \usepackage{amsmath}` |
\usepackage{amsmath} |
tabbed#
tab 1
tab 2
tab 3
tab 4
=== "tab 1"
tab 1
=== "tab 2"
tab 2
=== "tab 3"
tab 3
=== "tab 4"
tab 4
続けて書くけど区切りたいときは ===
のあとに !
を入れる;
#!/bin/bash
echo "Hello world!"
#include <stdio.h>
int main(void) {
printf("Hello world!\n");
return 0;
}
#include <iostream>
int main(void) {
std::cout << "Hello world!" << std::endl;
return 0;
}
using System;
class Program {
static void Main(string[] args) {
Console.WriteLine("Hello world!");
}
}
=== "Bash"
``` bash
#!/bin/bash
echo "Hello world!"
```
=== "C"
``` c
#include <stdio.h>
int main(void) {
printf("Hello world!\n");
return 0;
}
```
===! "C++"
``` c++
#include <iostream>
int main(void) {
std::cout << "Hello world!" << std::endl;
return 0;
}
```
=== "C#"
``` c#
using System;
class Program {
static void Main(string[] args) {
Console.WriteLine("Hello world!");
}
}
```
MkDocs+#
Font Awesome#
pip install fontawesome_markdown
mkdocs.yml
:
markdown_extensions:
- fontawesome_markdown
extra_css:
- "https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css"
:fa-external-link:
:fa-coffee:
:fa-twitter:
:fa-github:
Others#
indent spaces#
- Incorrect rendering of nested lists · Issue #545 · mkdocs/mkdocs
- MkDocs でスペース2個のインデントをリストのネストとして認識させたい場合 - stamemo
indentに必要はスペースはデフォルトでは 4
つになっている。
不便なので、2
つに変更する。
pip install mdx_truly_sane_lists
mkdocs.yml
:
markdown_extensions:
- mdx_truly_sane_lists
これで、スペース2つでもタブとして認識する。
Question
それでも、一部機能はスペース4つじゃないと効かない?
定義リスト#
mkdocs.yml
:
markdown_extensions:
- def_list
- たーむ
- にゃおああああああああああああああああああああああああああああうぎゃあああああああああああああああああああああああああああああああああああああああああなんでえええええええええええええええ
たーむ
: にゃおああああああああああああああああああああああああああああうぎゃあああああああああああああああああああああああああああああああああああああああああなんでえええええええええええええええ
リンクを新規タブで開く#
markdown_extensions:
- attr_list
kmarkdown と同じようにしてリンクを書く;
[リンク名](URL){target=_blank}