diff options
author | Simon Wilper | 2017-02-23 16:19:07 +0100 |
---|---|---|
committer | Simon Wilper | 2017-02-23 16:19:07 +0100 |
commit | 2aefdf2042d89696512bd5b14f93d78e9ace6769 (patch) | |
tree | 79f4b1a0a6f22ceeead57165d0d8451bf1a6252b | |
download | aur-2aefdf2042d89696512bd5b14f93d78e9ace6769.tar.gz |
initial commit
-rw-r--r-- | .SRCINFO | 13 | ||||
-rw-r--r-- | PKGBUILD | 30 | ||||
-rw-r--r-- | default.css | 86 | ||||
-rw-r--r-- | default.html | 11 | ||||
-rw-r--r-- | proc_tut.py | 74 |
5 files changed, 214 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..f9b9e0910e06 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,13 @@ +pkgbase = cutelyst-tutorial-git + pkgdesc = The Wiki tutorial from Github as a local copy + pkgver = 1.0.0 + pkgrel = 1 + url = http://cutelyst.org + arch = any + license = LGPL2.1 + makedepends = python2 + source = git+https://github.com/cutelyst/cutelyst.wiki.git + md5sums = SKIP + +pkgname = cutelyst-tutorial-git + diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..51d27b2d2002 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,30 @@ +# Maintainer: Simon Wilper <sxw@chronowerks.de> + +pkgname=('cutelyst-tutorial-git') +pkgver=1.0.0 +pkgrel=1 +pkgdesc="The Wiki tutorial from Github as a local copy" +arch=('any') +url="http://cutelyst.org" +license=('LGPL2.1') +makedepends=('python2') +source=('git+https://github.com/cutelyst/cutelyst.wiki.git') +md5sums=('SKIP') +_git_name='cutelyst.wiki' + +build() { + test ! -d html && mkdir html + for md in ${_git_name}/Tut*.md; do + echo -n "$md..." + python2 ../proc_tut.py $md html/$(basename $md .md).html + echo " done" + done +} + +package() { + cd $startdir + local t=usr/share/doc/cutelyst/tutorial + install -d -m755 ${pkgdir}/$t/ + install -m644 ${srcdir}/html/* ${pkgdir}/$t/ + install -m644 default.css ${pkgdir}/$t/ +} diff --git a/default.css b/default.css new file mode 100644 index 000000000000..e8a38a0cad24 --- /dev/null +++ b/default.css @@ -0,0 +1,86 @@ + +body { + font-family: sans-serif; +} + +h3, h4, h5 { + font-weight: normal; +} + +h3 { + margin: 40px 0 0 0; +} + +p { + line-height: 160%; +} + +.codehilite .hll { background-color: #ffffcc } +.codehilite { background: #f8f8f8; padding: 10px; } +.codehilite .c { color: #408080; font-style: italic } /* Comment */ +.codehilite .err { border: 1px solid #FF0000 } /* Error */ +.codehilite .k { color: #008000; font-weight: bold } /* Keyword */ +.codehilite .o { color: #666666 } /* Operator */ +.codehilite .ch { color: #408080; font-style: italic } /* Comment.Hashbang */ +.codehilite .cm { color: #408080; font-style: italic } /* Comment.Multiline */ +.codehilite .cp { color: #BC7A00 } /* Comment.Preproc */ +.codehilite .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */ +.codehilite .c1 { color: #408080; font-style: italic } /* Comment.Single */ +.codehilite .cs { color: #408080; font-style: italic } /* Comment.Special */ +.codehilite .gd { color: #A00000 } /* Generic.Deleted */ +.codehilite .ge { font-style: italic } /* Generic.Emph */ +.codehilite .gr { color: #FF0000 } /* Generic.Error */ +.codehilite .gh { color: #000080; font-weight: bold } /* Generic.Heading */ +.codehilite .gi { color: #00A000 } /* Generic.Inserted */ +.codehilite .go { color: #888888 } /* Generic.Output */ +.codehilite .gp { color: #000080; font-weight: bold } /* Generic.Prompt */ +.codehilite .gs { font-weight: bold } /* Generic.Strong */ +.codehilite .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ +.codehilite .gt { color: #0044DD } /* Generic.Traceback */ +.codehilite .kc { color: #008000; font-weight: bold } /* Keyword.Constant */ +.codehilite .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */ +.codehilite .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */ +.codehilite .kp { color: #008000 } /* Keyword.Pseudo */ +.codehilite .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */ +.codehilite .kt { color: #B00040 } /* Keyword.Type */ +.codehilite .m { color: #666666 } /* Literal.Number */ +.codehilite .s { color: #BA2121 } /* Literal.String */ +.codehilite .na { color: #7D9029 } /* Name.Attribute */ +.codehilite .nb { color: #008000 } /* Name.Builtin */ +.codehilite .nc { color: #0000FF; font-weight: bold } /* Name.Class */ +.codehilite .no { color: #880000 } /* Name.Constant */ +.codehilite .nd { color: #AA22FF } /* Name.Decorator */ +.codehilite .ni { color: #999999; font-weight: bold } /* Name.Entity */ +.codehilite .ne { color: #D2413A; font-weight: bold } /* Name.Exception */ +.codehilite .nf { color: #0000FF } /* Name.Function */ +.codehilite .nl { color: #A0A000 } /* Name.Label */ +.codehilite .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */ +.codehilite .nt { color: #008000; font-weight: bold } /* Name.Tag */ +.codehilite .nv { color: #19177C } /* Name.Variable */ +.codehilite .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */ +.codehilite .w { color: #bbbbbb } /* Text.Whitespace */ +.codehilite .mb { color: #666666 } /* Literal.Number.Bin */ +.codehilite .mf { color: #666666 } /* Literal.Number.Float */ +.codehilite .mh { color: #666666 } /* Literal.Number.Hex */ +.codehilite .mi { color: #666666 } /* Literal.Number.Integer */ +.codehilite .mo { color: #666666 } /* Literal.Number.Oct */ +.codehilite .sa { color: #BA2121 } /* Literal.String.Affix */ +.codehilite .sb { color: #BA2121 } /* Literal.String.Backtick */ +.codehilite .sc { color: #BA2121 } /* Literal.String.Char */ +.codehilite .dl { color: #BA2121 } /* Literal.String.Delimiter */ +.codehilite .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */ +.codehilite .s2 { color: #BA2121 } /* Literal.String.Double */ +.codehilite .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */ +.codehilite .sh { color: #BA2121 } /* Literal.String.Heredoc */ +.codehilite .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */ +.codehilite .sx { color: #008000 } /* Literal.String.Other */ +.codehilite .sr { color: #BB6688 } /* Literal.String.Regex */ +.codehilite .s1 { color: #BA2121 } /* Literal.String.Single */ +.codehilite .ss { color: #19177C } /* Literal.String.Symbol */ +.codehilite .bp { color: #008000 } /* Name.Builtin.Pseudo */ +.codehilite .fm { color: #0000FF } /* Name.Function.Magic */ +.codehilite .vc { color: #19177C } /* Name.Variable.Class */ +.codehilite .vg { color: #19177C } /* Name.Variable.Global */ +.codehilite .vi { color: #19177C } /* Name.Variable.Instance */ +.codehilite .vm { color: #19177C } /* Name.Variable.Magic */ +.codehilite .il { color: #666666 } /* Literal.Number.Integer.Long */ diff --git a/default.html b/default.html new file mode 100644 index 000000000000..a8279f6cc573 --- /dev/null +++ b/default.html @@ -0,0 +1,11 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> + <title>{{title}}</title> + <link href="default.css" type="text/css" rel="stylesheet" /> + </head> + <body> + {{contents}} + </body> +</html> diff --git a/proc_tut.py b/proc_tut.py new file mode 100644 index 000000000000..3469220843c7 --- /dev/null +++ b/proc_tut.py @@ -0,0 +1,74 @@ +import markdown +from markdown.preprocessors import Preprocessor +from markdown.postprocessors import Postprocessor +from markdown.extensions import Extension +import sys +import re +import os +import codecs +import jinja2 + +''' +Process Github Wiki Tutorial Pages +Simon Wilper +2017-02-24 +''' + +class BrokenLinkPreprocessor(Preprocessor): + ''' + Github Wiki inserts a space between link title and url what breaks + python's markdown processor. This Preprocessor fixes this + ''' + def run(self,lines): + new_lines = [] + for line in lines: + new_lines.append(re.sub(r"\] \(", '](', line)) + return new_lines + +class MkLocalLinkPostprocessor(Postprocessor): + ''' + In order to make interlinks work, add a .html suffix in all hrefs + but no the ones beginning with https? + ''' + def run(self,text): + new_text=re.sub( + r'href="(?!https?://)(.+?)"', + r'href="\1.html"', + text + ) + return new_text + +class FixGHLinksExtension(Extension): + def extendMarkdown(self, md, md_globals): + md.preprocessors.add( 'blpp', BrokenLinkPreprocessor(), + '_begin' ) + md.postprocessors.add( 'llpp', MkLocalLinkPostprocessor(), + '_begin' ) + +if len(sys.argv) < 3: + print('Give markdown source file and html output file') + sys.exit(-1) + +file_name = sys.argv[1] +output_file_name = sys.argv[2] + +input_file = codecs.open(file_name, mode="r", encoding="utf-8") +md_text = input_file.read() +html = markdown.markdown(md_text, extensions=[ + FixGHLinksExtension(), + 'markdown.extensions.codehilite', + 'markdown.extensions.fenced_code' + ]) + +t = jinja2.Environment( + loader=jinja2.FileSystemLoader( + os.path.dirname(os.path.realpath(__file__)) + ) + ).get_template('default.html') + +output_file = codecs.open( + output_file_name, "w", encoding="utf-8", + errors="xmlcharrefreplace" + ) + +output_file.write(t.render(title=file_name,contents=html)) |