mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 22:23:23 +00:00
Another version of the indice/exposants
This commit is contained in:
parent
579a68362d
commit
ecbfe0822f
@ -26,15 +26,15 @@ class SithInlineGrammar(InlineGrammar):
|
|||||||
underline = re.compile(
|
underline = re.compile(
|
||||||
r'^_{2}([\s\S]+?)_{2}(?!_)' # __word__
|
r'^_{2}([\s\S]+?)_{2}(?!_)' # __word__
|
||||||
)
|
)
|
||||||
exposant = re.compile(
|
exposant = re.compile( # FIXME Does not work for now
|
||||||
r'^\^([\s\S]+?)\^(?!\^)' # ^text^
|
r'^\^([\s\S]+?)\^' # ^text^
|
||||||
r'|'
|
# r'|' # FIXME doesn't properly works like this
|
||||||
r'^\^(\S*)' # ^word
|
# r'^\^(\S+)' # ^word
|
||||||
)
|
)
|
||||||
indice = re.compile( # XXX FIXME: don't work with inline code
|
indice = re.compile(
|
||||||
r'^_([\s\S]+?)_(?!_)' # _text_
|
r'^_([\s\S]+?)_' # _text_ (^` hack, because no other solution were found :/ this sadly prevent code in indices)
|
||||||
r'|'
|
# r'|' # FIXME doesn't properly works like this
|
||||||
r'^_(\S*)' # _word
|
# r'^_(\S+)' # _word
|
||||||
)
|
)
|
||||||
|
|
||||||
class SithInlineLexer(InlineLexer):
|
class SithInlineLexer(InlineLexer):
|
||||||
@ -49,11 +49,11 @@ class SithInlineLexer(InlineLexer):
|
|||||||
'link',
|
'link',
|
||||||
'reflink',
|
'reflink',
|
||||||
'nolink',
|
'nolink',
|
||||||
|
'exposant',
|
||||||
'double_emphasis',
|
'double_emphasis',
|
||||||
'emphasis',
|
'emphasis',
|
||||||
'underline',
|
'underline',
|
||||||
# 'indice',
|
'indice',
|
||||||
'exposant',
|
|
||||||
'code',
|
'code',
|
||||||
'linebreak',
|
'linebreak',
|
||||||
'strikethrough',
|
'strikethrough',
|
||||||
@ -66,11 +66,11 @@ class SithInlineLexer(InlineLexer):
|
|||||||
'link',
|
'link',
|
||||||
'reflink',
|
'reflink',
|
||||||
'nolink',
|
'nolink',
|
||||||
|
'exposant',
|
||||||
'double_emphasis',
|
'double_emphasis',
|
||||||
'emphasis',
|
'emphasis',
|
||||||
'underline',
|
'underline',
|
||||||
# 'indice',
|
'indice',
|
||||||
'exposant',
|
|
||||||
'code',
|
'code',
|
||||||
'linebreak',
|
'linebreak',
|
||||||
'strikethrough',
|
'strikethrough',
|
||||||
@ -82,11 +82,11 @@ class SithInlineLexer(InlineLexer):
|
|||||||
return self.renderer.underline(text)
|
return self.renderer.underline(text)
|
||||||
|
|
||||||
def output_exposant(self, m):
|
def output_exposant(self, m):
|
||||||
text = m.group(1) or m.group(2)
|
text = m.group(1)
|
||||||
return self.renderer.exposant(text)
|
return self.renderer.exposant(text)
|
||||||
|
|
||||||
def output_indice(self, m):
|
def output_indice(self, m):
|
||||||
text = m.group(1) or m.group(2)
|
text = m.group(1)
|
||||||
return self.renderer.indice(text)
|
return self.renderer.indice(text)
|
||||||
|
|
||||||
# Double emphasis rule changed
|
# Double emphasis rule changed
|
||||||
@ -124,11 +124,6 @@ class SithInlineLexer(InlineLexer):
|
|||||||
renderer = SithRenderer()
|
renderer = SithRenderer()
|
||||||
inline = SithInlineLexer(renderer)
|
inline = SithInlineLexer(renderer)
|
||||||
|
|
||||||
# enable the features
|
|
||||||
# inline.enable_indice()
|
|
||||||
# inline.enable_exposant()
|
|
||||||
# inline.enable_underline()
|
|
||||||
|
|
||||||
markdown = Markdown(renderer, inline=inline)
|
markdown = Markdown(renderer, inline=inline)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
@ -145,10 +140,9 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
* ~~Barrer du texte~~ : `~~texte~~`
|
* ~~Barrer du texte~~ : `~~texte~~`
|
||||||
|
|
||||||
* ^Mettre du texte^ en ^exposant : `^mot` ou `^texte^`
|
* Mettre ^du texte^ en ^exposant^ : `^mot` ou `^texte^`
|
||||||
just ^another test
|
|
||||||
|
|
||||||
* _Mettre du texte_ en _indice : `_mot` ou `_texte_`
|
* _Mettre du texte_ en _indice_ : `_mot` ou `_texte_`
|
||||||
|
|
||||||
* Pied de page [^en pied de page]
|
* Pied de page [^en pied de page]
|
||||||
|
|
||||||
@ -167,6 +161,8 @@ Un bloc de citation se crée ainsi :
|
|||||||
|
|
||||||
Il est possible d'intégrer de la syntaxe Markdown-AE dans un tel bloc.
|
Il est possible d'intégrer de la syntaxe Markdown-AE dans un tel bloc.
|
||||||
|
|
||||||
|
Petit *test* _sur_ ^une^ **seule** ^ligne pour voir^
|
||||||
|
|
||||||
"""
|
"""
|
||||||
print(markdown(text))
|
print(markdown(text))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user