Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whitepaper Update #641

Merged
merged 7 commits into from
Dec 16, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ private fun generateCodeStyle() {
val lines = file.readLines().toMutableList()
tempFile.printWriter().use { writer ->
val iterator = lines.iterator()
writer.writeln("\\section*{guide}")
writer.writeln("\\lstMakeShortInline[basicstyle=\\ttfamily\\bfseries]`")
while (iterator.hasNext()) {
var line = iterator.next()
Expand All @@ -53,6 +52,15 @@ private fun generateCodeStyle() {
?.removePrefix("</a>")
?.trim()
if (name.isNullOrEmpty() || number.isNullOrEmpty()) {
if (number.isNullOrEmpty() && name.isNullOrEmpty()) {
when (line.takeWhile { it == '#' }.count()) {
2 -> writer.writeln("""\section*{\textbf{${line.removePrefix("##").trim()}}}""")
3 -> writer.writeln("""\subsection*{\textbf{${line.removePrefix("###").trim()}}}""")
4 -> writer.writeln("""\subsubsection*{\textbf{${line.removePrefix("####").trim()}}}${"\n"}\leavevmode\newline""")
else -> {}
}
continue
}
error("String starts with # but has no number or name - $line")
}
when (number.count { it == '.' }) {
Expand Down Expand Up @@ -93,6 +101,7 @@ private fun generateCodeStyle() {
line = iterator.next()
while (iterator.hasNext() && line.trim().startsWith("|")) {
writer.writeln(line
.replace("&", "\\&")
.replace('|', '&')
.drop(1)
.dropLast(1)
Expand All @@ -118,9 +127,10 @@ private fun generateCodeStyle() {
}
}
val appendixFileLines = File("wp/sections/appendix.tex").readLines().toMutableList()
appendixFileLines.removeAll(appendixFileLines.subList(appendixFileLines.indexOf("\\section*{guide}"), appendixFileLines.lastIndex + 1))
appendixFileLines.removeAll(appendixFileLines.subList(appendixFileLines.indexOf("\\lstMakeShortInline[basicstyle=\\ttfamily\\bfseries]`"), appendixFileLines.lastIndex + 1))
appendixFileLines.addAll(tempFile.readLines())
File("wp/sections/appendix.tex").writeText(appendixFileLines.joinToString(separator = "\n"))
tempFile.delete()
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ val ITALIC_TEXT = Regex("""\*([A-Za-z ]+)\*""") // finds italic text in regular
@Suppress("VARIABLE_NAME_INCORRECT_FORMAT")
val BACKTICKS_TEXT = Regex("""`([^`]*)`""") // finds backtick in regular text (not used for now, may be we will need to use it in future)
@Suppress("VARIABLE_NAME_INCORRECT_FORMAT")
val ANCHORS = Regex("""\(#(.*)\)""") // finds anchors on rules and deletes them
val ANCHORS = Regex("""\(#([a-zA-Z0-9-.]*)\)""") // finds anchors on rules and deletes them
@Suppress("VARIABLE_NAME_INCORRECT_FORMAT")
val TABLE_COLUMN_NAMES = Regex("""[A-Za-z ]*""") // used to find column names in tables only
const val REGEX_PLACEHOLDER = "RE_PL_AC_E_ME"
Expand Down
Loading