bonus2: support special html chars
git-svn-id: svn+ssh://atelier.inf.usi.ch/home/bevilj/group-1@239 a672b425-5310-4d7a-af5c-997e18724b81
This commit is contained in:
parent
95b6720f2e
commit
884da05074
3 changed files with 17 additions and 2 deletions
bonus2
|
@ -13,7 +13,7 @@ Did you ever hear the tragedy of
|
|||
<b>Darth Plagueis</b> <i>The Wise</i>?<br>
|
||||
<code>I thought not</code>. It’s not a story the Jedi would tell you.</br>
|
||||
It’s a Sith legend. Darth Plagueis was a Dark Lord of the Sith,
|
||||
so powerful and so wise he could use the Force to influence the midichlorians to <u>create life…</u><br>
|
||||
so powerful & so wise he could use the Force to influence the midichlorians to <u>create life…</u><br>
|
||||
He had such a knowledge of the dark side that he could even keep the ones he cared about from dying.<br>
|
||||
The dark side of the Force is a pathway to many abilities some consider to be unnatural.<br>
|
||||
He became so powerful… the only thing he was afraid of was losing his power, which eventually, of course, he did.<br>
|
||||
|
@ -38,7 +38,7 @@ Unfortunately, he taught his apprentice everything he knew, then his apprentice
|
|||
|
||||
<h1>Fish</h1>
|
||||
|
||||
There's always <a href="{{ site.baseurl }}/bigger.html">bigger</a> fish
|
||||
There's always >> <a href="{{ site.baseurl }}/bigger.html">bigger</a> fish
|
||||
|
||||
<ul>
|
||||
<li><u>Hello there</u></li>
|
||||
|
@ -53,6 +53,8 @@ Dew it.
|
|||
{% endhighlight %}
|
||||
|
||||
|
||||
< Credits will do fine >
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>The</th>
|
||||
|
|
|
@ -60,6 +60,7 @@ class HtmlParser(private val singlePage: Boolean) {
|
|||
changeMono()
|
||||
changeParagraph()
|
||||
changeSection()
|
||||
changeSpecials()
|
||||
changeSubSection()
|
||||
changeSubSubSection()
|
||||
changeTable()
|
||||
|
|
|
@ -139,6 +139,15 @@ class HtmlToLatexWriter(private var content: String, private val singlePage: Boo
|
|||
if (singlePage) "\\subsection{" else "\\section{", "}\n")
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace special html chars with LaTeX equivalents
|
||||
*/
|
||||
fun changeSpecials() {
|
||||
HTML_SPECIALS_FROM.forEachIndexed { index, s ->
|
||||
content = content.replace(s, HTML_SPECIALS_TO[index])
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace <h2> with LaTeX \subsection
|
||||
*/
|
||||
|
@ -292,5 +301,8 @@ class HtmlToLatexWriter(private var content: String, private val singlePage: Boo
|
|||
"\\documentclass[hidelinks,12pt,a4paper,numbers=enddot]{scrartcl}\n\n" +
|
||||
"\\usepackage[margin=2cm]{geometry}\n" +
|
||||
"\\usepackage{hyperref}"
|
||||
|
||||
private val HTML_SPECIALS_FROM = arrayOf("&", "<", ">")
|
||||
private val HTML_SPECIALS_TO = arrayOf("\\&", "\\textless ", "\\textgreater ")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue