Commit 8ff3a188 authored by Denis Salem's avatar Denis Salem
Browse files

wip Latex suport

parent 53ec5129
......@@ -113,13 +113,12 @@
DONE | Fix pattern recursion issue (CodeHighlight).
DONE | Fix vertical scroll bar in code snippet.
WIP | Add reStructuredText support, remove do_not_use_markdown option.
TODO | Change nomenclature: Most of the usual patterns are changed. Fix doc.
WIP | Adding LaTeX2mathml support.
TODO | Support for video.
TODO | Add relevant templates for themes.
TODO | Add categories tree in entry.
TODO | Reorganize themes dependencies in setup (adding default templates, scripts, and pages to include).
TODO | SSH SUPPORT.
TODO | Add backup command.
TODO | Adding LaTeX support.
TODO | Split install and blog creation chapter in tutorial.
TODO | Allow disabling exportation of specific kind of thread.
TODO | Add more specific pattern to detect location (IfInCategories,IfInArchives,IfInFirstPage).
......@@ -129,6 +128,7 @@
TODO | add entry preview / full content.
TODO | Remove illegal character from path.
TODO | Open with navigator manual.
TODO | Change nomenclature: Most of the usual patterns are changed. Fix doc.
TODO | Add translation for Deutsch and Spanish.
TODO | Client-side search engine.
TODO | Fix unit test.
......@@ -34,6 +34,7 @@ from venc2.helpers import notify
from venc2.helpers import rm_tree_error_handler
from venc2.l10n import messages
from venc2.patterns.code_highlight import CodeHighlight
from venc2.patterns.latex2mathml import Latex2MathML
from venc2.patterns.contextual import extra_contextual_pattern_names
from venc2.patterns.non_contextual import non_contextual_pattern_names
from venc2.patterns.processor import Processor
......@@ -80,8 +81,9 @@ non_contextual_pattern_names_datastore = {
"ForBlogCategories" : "for_blog_categories"
}
non_contextual_pattern_names_code_highlight = {
"CodeHighlight" : code_highlight.highlight
non_contextual_pattern_names_ml = {
"CodeHighlight" : code_highlight.highlight,
"Latex2MathML" : Latex2MathML
}
contextual_pattern_names = {
......@@ -125,8 +127,8 @@ def export_blog(argv=list()):
for pattern_name in non_contextual_pattern_names_datastore.keys():
processor.set_function(pattern_name, getattr(datastore, non_contextual_pattern_names_datastore[pattern_name]))
for pattern_name in non_contextual_pattern_names_code_highlight.keys():
processor.set_function(pattern_name, non_contextual_pattern_names_code_highlight[pattern_name])
for pattern_name in non_contextual_pattern_names_ml.keys():
processor.set_function(pattern_name, non_contextual_pattern_names_ml[pattern_name])
for pattern_name in non_contextual_pattern_names.keys():
processor.set_function(pattern_name, non_contextual_pattern_names[pattern_name])
......
......@@ -54,15 +54,13 @@ class CodeHighlight:
code = argv[2]
result = pygments.highlight(code.replace("\:",":"), lexer, formatter).replace(".:",".:")
css = formatter.get_style_defs()
if argv[1]=="True":
css += "\n."+name+"table {width: 100%; display: block;}"
css += "\n."+name+"table tr {width: 100%; display: block;}"
css += "\n."+name+"table tbody {width: 100%; display: block;}"
css += "\n."+name+"table .linenos {width: 4%; display: inline-block;vertical-align: top;}"
css += "\n."+name+"table .code {width: 95%; display: inline-block;vertical-align: top;}"
css += "\n."+name+"table td pre {vertical-align: top; overflow: hidden; overflow-x: scroll;}"
else:
css += "\n."+name+" pre {overflow: hidden; overflow-x: scroll;}"
css += "\n."+name+"table {width: 100%; display: block;}"
css += "\n."+name+"table tr {width: 100%; display: block;}"
css += "\n."+name+"table tbody {width: 100%; display: block;}"
css += "\n."+name+"table .linenos {width: 4%; display: inline-block;vertical-align: top;}"
css += "\n."+name+"table .code {width: 95%; display: inline-block;vertical-align: top;}"
css += "\n."+name+"table td pre {vertical-align: top; overflow: hidden; overflow-x: scroll;}"
css += "\n."+name+" pre {overflow: hidden; overflow-x: scroll;}"
if not name+".css" in self._includes.keys():
self._includes[name+".css"] = css
......
#! /usr/bin/python3
# Copyright 2016, 2018 Denis Salem
#
# This file is part of VenC.
#
# VenC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# VenC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with VenC. If not, see <http://www.gnu.org/licenses/>.
import latex2mathml.converter
def Latex2MathML(argv):
latex = argv[0]
try:
return latex2mathml.converter.convert(latex)
except Exception as e:
print(argv[0], e)
......@@ -239,7 +239,7 @@ class Processor():
to_remove = list()
for index in pre_processed.patterns_index:
current_pattern = pre_processed.sub_strings[index][2:-2].split('::')[0]
if current_pattern == "CodeHighlight":
if current_pattern in ["CodeHighlight", "Latex2MathML"]:
pre_processed.keep_appart_from_markup_index.append(index)
if not current_pattern in self.blacklist:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment