Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
2 files changed, 39 insertions, 22 deletions
-rw-r--r--awk-edits/MEL-Presentation.awk8
-rw-r--r--awk-edits/MEL-parser.awk53
diff --git a/awk-edits/MEL-Presentation.awk b/awk-edits/MEL-Presentation.awk
index 849a8f8..7fae51d 100644
--- a/awk-edits/MEL-Presentation.awk
+++ b/awk-edits/MEL-Presentation.awk
@@ -1,4 +1,4 @@
-# .*(slides|teaching)/.*html
+# .*html
BEGIN {
#
@@ -43,7 +43,7 @@ BEGIN {
# Special cases
#
- MEL["presentation", MELSINGLE] = ORS \
+ MEL["presentation", MELINSERT] = ORS \
"<nav id=\"presentCont\">" ORS \
" <span id=\"prevSlideBtn\" class=\"btn nodisplay\">&#x2190;</span>" ORS \
" <a id=\"slideIndex\" class=\"nodisplay\" href=\"#slide-0\">0</a>" ORS \
@@ -60,14 +60,14 @@ BEGIN {
MEL["eqrows", MELOPEN] = "<div class=\"layout-table fixed-layout\"><div class=\"layout-row\">" # <table><tr> (layout-row > * is td)
MEL["eqrows", MELCLOSE] = "</div>"
- MEL["newrow", MELSINGLE] = "</div><div class=\"layout-row\">" # </tr><tr>
+ MEL["newrow", MELINSERT] = "</div><div class=\"layout-row\">" # </tr><tr>
#
# Generated tags
#
for (i = 1; i <= 9; i++) {
- MEL["br" i, MELSINGLE] = "<div class=\"lineb" i "\"></div>"
+ MEL["br" i, MELINSERT] = "<div class=\"lineb" i "\"></div>"
}
for (i = 5; i <= 95; i++) {
standardPresentationTag("width" i "%")
diff --git a/awk-edits/MEL-parser.awk b/awk-edits/MEL-parser.awk
index ebd68bd..d1eb4d5 100644
--- a/awk-edits/MEL-parser.awk
+++ b/awk-edits/MEL-parser.awk
@@ -1,4 +1,4 @@
-# .*(slides|teaching)/.*html
+# .*html
#
# == About ==
#
@@ -29,9 +29,11 @@
BEGIN {
newStack("mel")
- MELSINGLE = "s"
- MELOPEN = "o"
- MELCLOSE = "c"
+ MELOPEN = "o"
+ MELCLOSE = "c"
+ MELINSERT = "s"
+ MELPARAGRAPH = "p"
+ MELLINE = "l"
}
/<code>/ {
@@ -42,37 +44,52 @@ BEGIN {
melInsideCode = 0
}
-melInsideCode == 0 && /^[ \t]*(<p>)?&#38;/ {
+melInsideCode == 0 && /^[ \t]*(<p>|<dt>)?&#38;[{[()\]}:.]/ {
newLine = ""
lineCopy = $0
- while (match(lineCopy, /&#38;(((::|[[{(:.])[^[:space:].:[{(<>)}\]&]+)|[\]})])/)) {
- RSTART = RSTART + 5
- RLENGTH = RLENGTH - 5
+ paragraphed = 0
+ while (match(lineCopy, /&#38;(((::|[[{(:.])[^[:space:].:;[{(<>)}\]&]+)|[\]})])/)) {
+ RSTART += 5
+ RLENGTH -= 5
# Inside closing tag
if (RLENGTH == 1) {
replaceWith = MEL[topStack("mel"), MELCLOSE]
popStack("mel")
}
- # Inside opening tag
- else if (substr(lineCopy, RSTART, 1) ~ /[[{(]/) {
+ # Inside insert
+ else if (substr(lineCopy, RSTART, 1) == ".") {
name = substr(lineCopy, RSTART + 1, RLENGTH - 1)
- replaceWith = MEL[name, MELOPEN]
- pushStack("mel", name)
+ replaceWith = MEL[name, MELINSERT]
+ }
+ # Inside one line TODO
+ else if (substr(lineCopy, RSTART, 2) == "::") {
+ name = substr(lineCopy, RSTART + 2, RLENGTH - 2)
+
+ # RLENGTH = length(lineCopy)
+ replaceWith = MEL[name, MELLINE]
+ }
+ # Inside paragraph
+ else if (substr(lineCopy, RSTART, 1) == ":") {
+ name = substr(lineCopy, RSTART + 1, RLENGTH - 1)
+
+ replaceWith = " " MEL[name, MELPARAGRAPH]
+ RSTART -= 1
+ RLENGTH += 1
+ paragraphed = 1
}
- # Inside paragraph/one line/insert
- # TODO: currently all work as insert
+ # Inside opening tag
else {
- nameStart = 1 + (substr(lineCopy, RSTART + 1, 1) == ":")
- name = substr(lineCopy, RSTART + nameStart, RLENGTH - nameStart)
+ name = substr(lineCopy, RSTART + 1, RLENGTH - 1)
- replaceWith = MEL[name, MELSINGLE]
+ replaceWith = MEL[name, MELOPEN]
+ pushStack("mel", name)
}
newLine = newLine substr(lineCopy, 0, RSTART - 6) replaceWith
lineCopy = substr(lineCopy, RSTART + RLENGTH)
}
$0 = newLine lineCopy
- if (length(newLine) > 0)
+ if (paragraphed == 0 && length(newLine) > 0)
gsub(/(<p>|<\/p>)/, "")
}