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
2e42f1f41b
commit
1b89bcde4d
|
@ -13,7 +13,7 @@ Did you ever hear the tragedy of
|
||||||
<b>Darth Plagueis</b> <i>The Wise</i>?<br>
|
<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>
|
<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,
|
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>
|
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>
|
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>
|
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>
|
<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>
|
<ul>
|
||||||
<li><u>Hello there</u></li>
|
<li><u>Hello there</u></li>
|
||||||
|
@ -53,6 +53,8 @@ Dew it.
|
||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
|
|
||||||
|
|
||||||
|
< Credits will do fine >
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>The</th>
|
<th>The</th>
|
||||||
|
|
|
@ -60,6 +60,7 @@ class HtmlParser(private val singlePage: Boolean) {
|
||||||
changeMono()
|
changeMono()
|
||||||
changeParagraph()
|
changeParagraph()
|
||||||
changeSection()
|
changeSection()
|
||||||
|
changeSpecials()
|
||||||
changeSubSection()
|
changeSubSection()
|
||||||
changeSubSubSection()
|
changeSubSubSection()
|
||||||
changeTable()
|
changeTable()
|
||||||
|
|
|
@ -139,6 +139,15 @@ class HtmlToLatexWriter(private var content: String, private val singlePage: Boo
|
||||||
if (singlePage) "\\subsection{" else "\\section{", "}\n")
|
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
|
* 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" +
|
"\\documentclass[hidelinks,12pt,a4paper,numbers=enddot]{scrartcl}\n\n" +
|
||||||
"\\usepackage[margin=2cm]{geometry}\n" +
|
"\\usepackage[margin=2cm]{geometry}\n" +
|
||||||
"\\usepackage{hyperref}"
|
"\\usepackage{hyperref}"
|
||||||
|
|
||||||
|
private val HTML_SPECIALS_FROM = arrayOf("&", "<", ">")
|
||||||
|
private val HTML_SPECIALS_TO = arrayOf("\\&", "\\textless ", "\\textgreater ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue