diff options
| Commit | 867b5015fda689bc5414557557a00cd8ad62699d (patch) | |
|---|---|---|
| Author | 2024-02-25 12:51:29 +0200 | |
| Committer | 2024-02-25 12:51:52 +0200 | |
| Files | 97cd3d9e14aaceecfc3f8afda1c6b70dc2aecc6c | |
| syndamia.com-867b5015fda689bc5414557557a00cd8ad62699d.tar syndamia.com-867b5015fda689bc5414557557a00cd8ad62699d.tar.gz syndamia.com-867b5015fda689bc5414557557a00cd8ad62699d.zip | ||
| Parent | 86a913d3e15803d7a8775d86601e19cf5f720b96 (diff) | |
(awk-edits) Properly implemented MEL paragraph tag
2 files changed, 39 insertions, 22 deletions
| -rw-r--r-- | awk-edits/MEL-Presentation.awk | 8 | ||||
| -rw-r--r-- | awk-edits/MEL-parser.awk | 53 |
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\">←</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>)?&/ { +melInsideCode == 0 && /^[ \t]*(<p>|<dt>)?&[{[()\]}:.]/ { newLine = "" lineCopy = $0 - while (match(lineCopy, /&(((::|[[{(:.])[^[:space:].:[{(<>)}\]&]+)|[\]})])/)) { - RSTART = RSTART + 5 - RLENGTH = RLENGTH - 5 + paragraphed = 0 + while (match(lineCopy, /&(((::|[[{(:.])[^[: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>)/, "") } |