From 6491006a7e64574605a4fe85c2e37ce36aec4eb3 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 27 Apr 2020 11:30:39 -0400 Subject: rename & house utils; work on markup conversion - new dir for markup tools misc/util/d/tools/markup_conversion - start looking at tools for converting - endnotes from binary to inline - sisu.rb to sisu spine in d - look at conversion of document headers to yaml from - bespoke sisu headers (original .rb) - sdlang - toml --- .gitignore | 4 - makefile | 6 +- misc/util/d/tools/endnotes_inline_from_binary.d | 127 --- misc/util/d/tools/markup_conversion/README | 1 + .../endnotes_inline_from_binary.d | 127 +++ .../d/tools/markup_conversion/markup_changes.d | 136 +++ .../markup_changes_header_and_content.d | 244 +++++ ...arkup_conversion_from_sisu_ruby_to_sisu_spine.d | 354 ++++++++ org/spine_build_scaffold.org | 10 +- org/spine_syntax_highlighting_emacs.org | 539 ----------- org/spine_syntax_highlighting_vim.org | 984 --------------------- org/util_spine_markup_conversion_from_sisu.org | 951 ++++++++++++++++++++ org/util_spine_syntax_highlighting_emacs.org | 539 +++++++++++ org/util_spine_syntax_highlighting_vim.org | 984 +++++++++++++++++++++ 14 files changed, 3344 insertions(+), 1662 deletions(-) delete mode 100755 misc/util/d/tools/endnotes_inline_from_binary.d create mode 100644 misc/util/d/tools/markup_conversion/README create mode 100755 misc/util/d/tools/markup_conversion/endnotes_inline_from_binary.d create mode 100644 misc/util/d/tools/markup_conversion/markup_changes.d create mode 100755 misc/util/d/tools/markup_conversion/markup_changes_header_and_content.d create mode 100755 misc/util/d/tools/markup_conversion/markup_conversion_from_sisu_ruby_to_sisu_spine.d delete mode 100644 org/spine_syntax_highlighting_emacs.org delete mode 100644 org/spine_syntax_highlighting_vim.org create mode 100644 org/util_spine_markup_conversion_from_sisu.org create mode 100644 org/util_spine_syntax_highlighting_emacs.org create mode 100644 org/util_spine_syntax_highlighting_vim.org diff --git a/.gitignore b/.gitignore index dbfeee5..f0affed 100644 --- a/.gitignore +++ b/.gitignore @@ -21,10 +21,6 @@ !org !misc !misc/** -!util -!util/** -!editor-syntax-etc -!editor-syntax-etc/** !ext_lib !ext_lib/** !src diff --git a/makefile b/makefile index 915177e..05df752 100644 --- a/makefile +++ b/makefile @@ -162,7 +162,8 @@ skel: mkdir -p build; \ mkdir -p views; \ mkdir -p data; \ - mkdir -p misc/util; \ + mkdir -p misc/util/d/cgi/search/cgi-bin/src; \ + mkdir -p misc/util/d/tools/markup_conversion; \ mkdir -p misc/editor-syntax-etc/emacs; \ mkdir -p misc/editor-syntax-etc/vim/syntax; \ mkdir -p misc/editor-syntax-etc/vim/colors; \ @@ -196,7 +197,8 @@ expunge: distclean: expunge distclean_and_init: expunge mkdir -p views; \ - mkdir -p misc/util; \ + mkdir -p misc/util/d/cgi/search/cgi-bin/src; \ + mkdir -p misc/util/d/tools/markup_conversion; \ mkdir -p misc/editor-syntax-etc/emacs; \ mkdir -p misc/editor-syntax-etc/vim/syntax; \ mkdir -p misc/editor-syntax-etc/vim/colors; \ diff --git a/misc/util/d/tools/endnotes_inline_from_binary.d b/misc/util/d/tools/endnotes_inline_from_binary.d deleted file mode 100755 index 4d9ceb0..0000000 --- a/misc/util/d/tools/endnotes_inline_from_binary.d +++ /dev/null @@ -1,127 +0,0 @@ -#!/usr/bin/env rdmd -/+ - - read in file .sst .ssi .ssm - - loop twice - - first - - check for and skip code blocks - - use unique code marker for endnote markers in text and give an endnote - number ★1, increment - - extract all endnotes in array - - second - - check that the footnote marker number count matches the number of notes - in the array - - if they match either: - - substitute each endnote marker with the array footnote[number-1] - - substitute each endnote marker with footnote - as inlined footnote markup (footnote number not needed) - - if they do not match exit - - check whether changes have been made - - if so write file with inline footnotes in sub-directory converted_output_/ - using the same name as the original file - - else, exit -+/ -import std.stdio; -import std.file; -import std.array : split; -import std.exception; -import core.stdc.errno; -import std.regex; -import std.format; -import std.conv; -void main(string[] args) { - foreach(arg; args[1..$]) { - if ( - !(arg.match(regex(r"--\w+"))) - && arg.match(regex(r"\w+?\.ss[itm]")) - ) { - writeln(arg); - string filename = arg; - try { - string[] contents, endnotes, endnote_refs; - string text = filename.readText; - string[] paragraphs = text.split("\n\n"); - int endnote_ref_count = 0; - int[string] type = [ - "curly_code" : 0, - "tic_code" : 0, - ]; - static comment = ctRegex!(`^%+ `); - static block_tic_code_open = ctRegex!("^`{3} code(?:[.](?P[a-z][0-9a-z#+_]+))?(?:[(](?P[ a-zA-Z0-9;:,]*)[)])?"); - static block_tic_close = ctRegex!("^(`{3})$","m"); - static block_curly_code_open = ctRegex!(`^(?:code(?:[.](?P[a-z][0-9a-z_]+))?(?:[(](?P[ a-zA-Z0-9;:,]*)[)])?[{][ ]*$)`); - static block_curly_code_close = ctRegex!(`^([}]code)`); - auto rgx_endnote_ref = ctRegex!(`([~]\^)(?P[)\]]? |$)`, "gm"); - auto rgx_endnote = ctRegex!(`^\^~\s+(.+|\n)`, "gm"); - foreach (paragraph; paragraphs) { /+ loop to gather binary endnotes +/ - if ( !( type["curly_code"] == 1 || type["tic_code"] == 1) - && paragraph.match(rgx_endnote) - ) { - endnotes ~= replaceAll!(m => m[1]) - (paragraph, rgx_endnote); - } else { - if ( type["curly_code"] == 1 - && paragraph.matchFirst(block_curly_code_close) - ) { - type["curly_code"] = 0; - } else if (type["tic_code"] == 1 - && paragraph.matchFirst(block_tic_close) - ) { - type["tic_code"] = 0; - } else if ( type["curly_code"] == 1 || type["tic_code"] == 1) { - // prevent search for endnotes - } else if (paragraph.matchFirst(block_curly_code_open)) { - type["curly_code"] = 1; - } else if (paragraph.matchFirst(block_tic_code_open)) { - type["tic_code"] = 1; - } else if (auto m = paragraph.matchAll(rgx_endnote_ref)) { - foreach (n; m) { - endnote_ref_count++; // endnote_refs ~= (n.captures[1]); - } - } - contents ~= paragraph; - } - } - if (endnotes.length == endnote_ref_count) { - import std.outbuffer; - writeln("endnote ref count: ", endnote_ref_count); - writeln("number of binary endnotes: ", endnotes.length); - int endnote_count = -1; - auto buffer = new OutBuffer(); - foreach (content; contents) { /+ loop to inline endnotes +/ - content = replaceAll!(m => "~{ " ~ endnotes[++endnote_count] ~ " }~" ~ m["tail"] ) - (content, rgx_endnote_ref); - buffer.write(content ~ "\n\n"); - } - if (buffer) { - try { - string dir_out = "converted_output_"; - string path_and_file_out = dir_out ~ "/" ~ filename; - dir_out.mkdirRecurse; - auto f = File(path_and_file_out, "w"); - f.write(buffer); - writeln("wrote: ", path_and_file_out); - } catch (FileException ex) { - writeln("did not write file"); - // Handle errors - } - } - } else { - writeln("ERROR binary endnote mismatch, check markup,\nmisatch in the number of endnotes & endnote references!"); - writeln(" number of endnotes: ", endnotes.length); - writeln(" number of endnote refs: ", endnote_ref_count); // endnote_refs.length, - } - // assert(endnotes.length == endnote_ref_count); - } catch (ErrnoException ex) { - switch(ex.errno) { - case EPERM: - case EACCES: // Permission denied - break; - case ENOENT: // File does not exist - break; - default: // Handle other errors - break; - } - } - } - } -} diff --git a/misc/util/d/tools/markup_conversion/README b/misc/util/d/tools/markup_conversion/README new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/misc/util/d/tools/markup_conversion/README @@ -0,0 +1 @@ + diff --git a/misc/util/d/tools/markup_conversion/endnotes_inline_from_binary.d b/misc/util/d/tools/markup_conversion/endnotes_inline_from_binary.d new file mode 100755 index 0000000..abd4e45 --- /dev/null +++ b/misc/util/d/tools/markup_conversion/endnotes_inline_from_binary.d @@ -0,0 +1,127 @@ +#!/usr/bin/env rdmd +/+ + - read in file .sst .ssi .ssm + - loop twice + - first + - check for and skip code blocks + - use unique code marker for endnote markers in text and give an endnote + number ★1, increment + - extract all endnotes in array + - second + - check that the footnote marker number count matches the number of notes + in the array + - if they match either: + - substitute each endnote marker with the array footnote[number-1] + - substitute each endnote marker with footnote + as inlined footnote markup (footnote number not needed) + - if they do not match exit + - check whether changes have been made + - if so write file with inline footnotes in sub-directory converted_output_/ + using the same name as the original file + - else, exit ++/ +import std.stdio; +import std.file; +import std.array : split; +import std.exception; +import core.stdc.errno; +import std.regex; +import std.format; +import std.conv; +void main(string[] args) { + static comment = ctRegex!(`^%+ `); + static block_tic_code_open = ctRegex!("^`{3} code(?:[.](?P[a-z][0-9a-z#+_]+))?(?:[(](?P[ a-zA-Z0-9;:,]*)[)])?"); + static block_tic_close = ctRegex!("^(`{3})$","m"); + static block_curly_code_open = ctRegex!(`^(?:code(?:[.](?P[a-z][0-9a-z_]+))?(?:[(](?P[ a-zA-Z0-9;:,]*)[)])?[{][ ]*$)`); + static block_curly_code_close = ctRegex!(`^([}]code)`); + auto rgx_endnote_ref = ctRegex!(`([~]\^)(?P[)\]]? |$)`, "gm"); + auto rgx_endnote = ctRegex!(`^\^~\s+(.+|\n)`, "gm"); + foreach(arg; args[1..$]) { + if ( + !(arg.match(regex(r"--\w+"))) + && arg.match(regex(r"\w+?\.ss[itm]")) + ) { + writeln(arg); + string filename = arg; + try { + string[] contents, endnotes, endnote_refs; + string text = filename.readText; + string[] paragraphs = text.split("\n\n"); + int endnote_ref_count = 0; + int[string] type = [ + "curly_code" : 0, + "tic_code" : 0, + ]; + foreach (paragraph; paragraphs) { /+ loop to gather binary endnotes +/ + if ( !( type["curly_code"] == 1 || type["tic_code"] == 1) + && paragraph.match(rgx_endnote) + ) { + endnotes ~= replaceAll!(m => m[1]) + (paragraph, rgx_endnote); + } else { + if ( type["curly_code"] == 1 + && paragraph.matchFirst(block_curly_code_close) + ) { + type["curly_code"] = 0; + } else if (type["tic_code"] == 1 + && paragraph.matchFirst(block_tic_close) + ) { + type["tic_code"] = 0; + } else if ( type["curly_code"] == 1 || type["tic_code"] == 1) { + // skip, prevent search for endnotes + } else if (paragraph.matchFirst(block_curly_code_open)) { + type["curly_code"] = 1; + } else if (paragraph.matchFirst(block_tic_code_open)) { + type["tic_code"] = 1; + } else if (auto m = paragraph.matchAll(rgx_endnote_ref)) { + foreach (n; m) { + endnote_ref_count++; // endnote_refs ~= (n.captures[1]); + } + } + contents ~= paragraph; + } + } + if (endnotes.length == endnote_ref_count) { + import std.outbuffer; + writeln("endnote ref count: ", endnote_ref_count); + writeln("number of binary endnotes: ", endnotes.length); + int endnote_count = -1; + auto buffer = new OutBuffer(); + foreach (content; contents) { /+ loop to inline endnotes +/ + content = replaceAll!(m => "~{ " ~ endnotes[++endnote_count] ~ " }~" ~ m["tail"] ) + (content, rgx_endnote_ref); + buffer.write(content ~ "\n\n"); + } + if (buffer) { + try { + string dir_out = "converted_output_"; + string path_and_file_out = dir_out ~ "/" ~ filename; + dir_out.mkdirRecurse; + auto f = File(path_and_file_out, "w"); + f.write(buffer); + writeln("wrote: ", path_and_file_out); + } catch (FileException ex) { + writeln("did not write file"); + // Handle errors + } + } + } else { + writeln("ERROR binary endnote mismatch, check markup,\nmisatch in the number of endnotes & endnote references!"); + writeln(" number of endnotes: ", endnotes.length); + writeln(" number of endnote refs: ", endnote_ref_count); // endnote_refs.length, + } + // assert(endnotes.length == endnote_ref_count); + } catch (ErrnoException ex) { + switch(ex.errno) { + case EPERM: + case EACCES: // Permission denied + break; + case ENOENT: // File does not exist + break; + default: // Handle other errors + break; + } + } + } + } +} diff --git a/misc/util/d/tools/markup_conversion/markup_changes.d b/misc/util/d/tools/markup_conversion/markup_changes.d new file mode 100644 index 0000000..4274f78 --- /dev/null +++ b/misc/util/d/tools/markup_conversion/markup_changes.d @@ -0,0 +1,136 @@ +#!/usr/bin/env rdmd +/+ + - read in file .sst .ssi .ssm + - loop twice + - first + - check for and skip code blocks + - use unique code marker for endnote markers in text and give an endnote + number ★1, increment + - extract all endnotes in array + - second + - check that the footnote marker number count matches the number of notes + in the array + - if they match either: + - substitute each endnote marker with the array footnote[number-1] + - substitute each endnote marker with footnote + as inlined footnote markup (footnote number not needed) + - if they do not match exit + - check whether changes have been made + - if so write file with inline footnotes in sub-directory converted_output_/ + using the same name as the original file + - else, exit ++/ +import std.stdio; +import std.file; +import std.array : split; +import std.exception; +import core.stdc.errno; +import std.regex; +import std.format; +import std.conv; +void main(string[] args) { + static comment = ctRegex!(`^%+ `); + static block_tic_code_open = ctRegex!("^`{3} code(?:[.](?P[a-z][0-9a-z#+_]+))?(?:[(](?P[ a-zA-Z0-9;:,]*)[)])?"); + static block_tic_close = ctRegex!("^(`{3})$","m"); + static block_curly_code_open = ctRegex!(`^(?:code(?:[.](?P[a-z][0-9a-z_]+))?(?:[(](?P[ a-zA-Z0-9;:,]*)[)])?[{][ ]*$)`); + static block_curly_code_close = ctRegex!(`^([}]code)`); + auto rgx_endnote_ref = ctRegex!(`([~]\^)(?P[)\]]? |$)`, "gm"); + auto rgx_endnote = ctRegex!(`^\^~\s+(.+|\n)`, "gm"); + foreach(arg; args[1..$]) { + if ( + !(arg.match(regex(r"--\w+"))) + && arg.match(regex(r"\w+?\.ss[itm]")) + ) { + writeln(arg); + string filename = arg; + try { + string[] contents, endnotes, endnote_refs; + string text = filename.readText; + string[] paragraphs = text.split("\n\n"); + int endnote_ref_count = 0; + int[string] type = [ + "curly_code" : 0, + "tic_code" : 0, + ]; + foreach (paragraph; paragraphs) { /+ loop to gather binary endnotes +/ + if ( !( type["curly_code"] == 1 || type["tic_code"] == 1) + && paragraph.match(rgx_endnote) + ) { + endnotes ~= replaceAll!(m => m[1]) + (paragraph, rgx_endnote); + } else { + if ( type["curly_code"] == 1 || type["tic_code"] == 1 + || paragraph.matchFirst(block_curly_code_open) + || paragraph.matchFirst(block_tic_code_open) + ) { /+ code blocks identified, no munging +/ + if ( type["curly_code"] == 1 + && paragraph.matchFirst(block_curly_code_close) + ) { + type["curly_code"] = 0; + } else if (type["tic_code"] == 1 + && paragraph.matchFirst(block_tic_close) + ) { + type["tic_code"] = 0; + } else if (paragraph.matchFirst(block_curly_code_open)) { + type["curly_code"] = 1; + } else if (paragraph.matchFirst(block_tic_code_open)) { + type["tic_code"] = 1; + } + contents ~= paragraph; + } else { /+ regular content, not a code block +/ + if (auto m = paragraph.matchAll(rgx_endnote_ref)) { + foreach (n; m) { + endnote_ref_count++; // endnote_refs ~= (n.captures[1]); + } + } + paragraph = replaceAll!(m => " \\\\ " ) + (paragraph, regex(r"\s*<(?:/\s*|:)?br>\s*")); // (paragraph, regex(r"(
)")); + contents ~= paragraph; + } + } + } + { + import std.outbuffer; + auto buffer = new OutBuffer(); + if (endnotes.length == endnote_ref_count) { + // writeln("endnote ref count: ", endnote_ref_count); + // writeln("number of binary endnotes: ", endnotes.length); + int endnote_count = -1; + foreach (content; contents) { /+ loop to inline endnotes +/ + content = replaceAll!(m => "~{ " ~ endnotes[++endnote_count] ~ " }~" ~ m["tail"] ) + (content, rgx_endnote_ref); // endnote_ref cannot occur in a code block or else fail + buffer.write(content ~ "\n\n"); + } + if (buffer) { + try { + string dir_out = "converted_output_"; + string path_and_file_out = dir_out ~ "/" ~ filename; + dir_out.mkdirRecurse; + auto f = File(path_and_file_out, "w"); + f.write(buffer); + writeln("wrote: ", path_and_file_out); + } catch (FileException ex) { + writeln("did not write file"); + // Handle errors + } + } + } else { + foreach (content; contents) { /+ loop to inline endnotes +/ + buffer.write(content ~ "\n\n"); + } + } + } + } catch (ErrnoException ex) { + switch(ex.errno) { + case EPERM: + case EACCES: // Permission denied + break; + case ENOENT: // File does not exist + break; + default: // Handle other errors + break; + } + } + } + } +} diff --git a/misc/util/d/tools/markup_conversion/markup_changes_header_and_content.d b/misc/util/d/tools/markup_conversion/markup_changes_header_and_content.d new file mode 100755 index 0000000..86792ff --- /dev/null +++ b/misc/util/d/tools/markup_conversion/markup_changes_header_and_content.d @@ -0,0 +1,244 @@ +#!/usr/bin/env rdmd +/+ + - read in file .sst .ssi .ssm + - loop twice + - first + - check for and skip code blocks + - use unique code marker for endnote markers in text and give an endnote + number ★1, increment + - extract all endnotes in array + - second + - check that the footnote marker number count matches the number of notes + in the array + - if they match either: + - substitute each endnote marker with the array footnote[number-1] + - substitute each endnote marker with footnote + as inlined footnote markup (footnote number not needed) + - if they do not match exit + - check whether changes have been made + - if so write file with inline footnotes in sub-directory converted_output_/ + using the same name as the original file + - else, exit ++/ +import std.stdio; +import std.file; +import std.array : split; +import std.exception; +// import std.range; +import core.stdc.errno; +import std.regex; +import std.format; +import std.conv; +void main(string[] args) { + static heading_a = ctRegex!(`^:?[A][~] `, "m"); + static comment = ctRegex!(`^%+ `); + static block_tic_code_open = ctRegex!("^`{3} code(?:[.](?P[a-z][0-9a-z#+_]+))?(?:[(](?P[ a-zA-Z0-9;:,]*)[)])?"); + static block_tic_close = ctRegex!("^(`{3})$","m"); + static block_curly_code_open = ctRegex!(`^(?:code(?:[.](?P[a-z][0-9a-z_]+))?(?:[(](?P[ a-zA-Z0-9;:,]*)[)])?[{][ ]*$)`); + static block_curly_code_close = ctRegex!(`^([}]code)`); + auto rgx_endnote_ref = ctRegex!(`([~]\^)(?P[)\]]? |$)`, "gm"); + auto rgx_endnote = ctRegex!(`^\^~\s+(.+|\n)`, "gm"); + char[][] header0Content1(in string src_text) { // cast(char[]) + /+ split string on _first_ match of "^:?A~\s" into [header, content] array/tuple +/ + char[][] header_and_content; + auto m = (cast(char[]) src_text).matchFirst(heading_a); + header_and_content ~= m.pre; + header_and_content ~= m.hit ~ m.post; + assert(header_and_content.length == 2, + "document markup is broken, header body split == " + ~ header_and_content.length.to!string + ~ "; (header / body array split should == 2 (split is on level A~))" + ); + return header_and_content; + } + foreach(arg; args[1..$]) { + if ( + !(arg.match(regex(r"--\w+"))) + && arg.match(regex(r"\w+?\.ss[itm]")) + ) { + writeln(arg); + string filename = arg; + try { + string[] munged_header, munged_contents, munged_endnotes, endnote_refs; + string text = filename.readText; + char[][] hc = header0Content1(text); + char[] src_header = hc[0]; + string[] headers = src_header.to!string.split("\n\n"); + char[] src_txt = hc[1]; + string[] paragraphs = src_txt.to!string.split("\n\n"); + int endnote_ref_count = 0; + int[string] type = [ + "curly_code" : 0, + "tic_code" : 0, + ]; + string _tmp_header; + foreach (h_; headers) { /+ loop to inline endnotes +/ + _tmp_header = ""; + if (h_.match(regex(r"^[@\[]?title[:\]]?"))) { // title + if (auto m = h_.match(regex(r"^@title:(?:\s+(?P.+)|$)"))) { // sisu bespoke markup + if (m.captures["c"].length == 0) { + _tmp_header ~= "title:"; + } else { + _tmp_header ~= "title:\n main: " ~ "\"" ~ m.captures["c"] ~ "\""; + } + } else if (auto m = h_.match(regex(r"^title\s*=\s*(?P.+)"))) { // toml? + if (m.captures["c"].length == 0) { + _tmp_header ~= "title:"; + } else { + _tmp_header ~= "title:\n main: " ~ "\"" ~ m.captures["c"] ~ "\""; + } + } else if (auto m = h_.match(regex(r"^\[title\]"))) { // toml markup + _tmp_header ~= "title:"; + } else if (auto m = h_.match(regex(r"^title(?:\s+(?P.+)|\s+\\$)"))) { // sdlang markup + if (m.captures["c"].length == 0) { + _tmp_header ~= "title:"; + } else { + _tmp_header ~= "title:\n main: " ~ "\"" ~ m.captures["c"] ~ "\""; + } + } + if (h_.match(regex(r"^\s*[:]?(?:main)[:= ]?", "m"))) { + if (auto m = h_.match(regex(r"^\s+(?P:main):(?:\s+(?P.+)|$)", "m"))) { // sisu bespoke markup + _tmp_header ~= " main: " ~ "\"" ~ m.captures["c"] ~ "\""; + } else if (auto m = h_.match(regex(r"^\s*(?Pmain)\s*=\s*(?P.+)", "m"))) { // toml? + _tmp_header ~= " main: " ~ m.captures["c"]; + } else if (auto m = h_.match(regex(r"^\s+(?Pmain)(?:\s*\s*(?P.+)|$)", "m"))) { // toml markup + _tmp_header ~= " main: " ~ "\"" ~ m.captures["c"] ~ "\""; + } else if (auto m = h_.match(regex(r"^\s+(?Pmain)(?:\s+(?P.+)|\s+\\$)", "m"))) { // sdlang markup + _tmp_header ~= " main: " ~ "\"" ~ m.captures["c"] ~ "\""; + } + } + if (h_.match(regex(r"^\s*[:]?(?:sub(title)?)[:= ]?", "m"))) { + if (auto m = h_.match(regex(r"^\s+:sub(?:title)?:(?:\s+(?P.+)|$)", "m"))) { // sisu bespoke markup + _tmp_header ~= " subtitle: " ~ "\"" ~ m.captures["c"] ~ "\""; + } else if (auto m = h_.match(regex(r"^\s*sub(?:title)?\s*=\s*(?P.+)$", "m"))) { // toml? + _tmp_header ~= " subtitle: " ~ m.captures["c"]; + } else if (auto m = h_.match(regex(r"^\s+(?:title)?(?:\s*\s*(?P.+)|$)", "m"))) { // toml markup + _tmp_header ~= " subtitle: " ~ "\"" ~ m.captures["c"] ~ "\""; + } else if (auto m = h_.match(regex(r"^\s+(?:title)?(?:\s+(?P.+)|\s+\\$)", "m"))) { // sdlang markup + _tmp_header ~= " subtitle: " ~ "\"" ~ m.captures["c"] ~ "\""; + } + } + } + if (h_.match(regex(r"^[@\[]?rights[:\]]?"))) { // rights + if (auto m = h_.match(regex(r"^@rights:[ ]+(?P.+)$"))) { // sisu bespoke markup + _tmp_header ~= "rights: \n copyright: \"" ~ m.captures["c"] ~ "\""; + } else if (auto m = h_.match(regex(r"^@rights:"))) { // sisu bespoke markup + _tmp_header ~= "rights:"; + } else if (auto m = h_.match(regex(r"^\[rights\]", "m"))) { // toml markup + _tmp_header ~= "rights:"; + } else if (auto m = h_.match(regex(r"^rights:"))) { // sdlang markup + _tmp_header ~= "rights:"; + } + if (h_.match(regex(r"^\s*[:]?copyright[:= ]?", "m"))) { + if (auto m = h_.match(regex(r"^\s+:copyright:(?:\s+(?P.+)|$)", "m"))) { // sisu bespoke markup + _tmp_header ~= " copyright: " ~ "\"" ~ m.captures["c"] ~ "\""; + } else if (auto m = h_.match(regex(r"^\s*copyright\s*=\s*(?P.+)", "m"))) { // toml? + _tmp_header ~= " copyright: " ~ m.captures["c"]; + } else if (auto m = h_.match(regex(r"^\s+copyright(?:\s*\s*(?P.+)|$)", "m"))) { // toml markup + _tmp_header ~= " copyright: " ~ "\"" ~ m.captures["c"] ~ "\""; + } else if (auto m = h_.match(regex(r"^\s+copyright(?:\s+(?P.+)|\s+\\$)", "m"))) { // sdlang markup + _tmp_header ~= " copyright: " ~ "\"" ~ m.captures["c"] ~ "\""; + } + } + if (h_.match(regex(r"^\s*[:]?licen[cs]e[:= ]?", "m"))) { + if (auto m = h_.match(regex(r"^\s+:licen[cs]e:(?:\s+(?P.+)|$)", "m"))) { // sisu bespoke markup + _tmp_header ~= " license: " ~ "\"" ~ m.captures["c"] ~ "\""; + } else if (auto m = h_.match(regex(r"^\s*licen[cs]e\s*=\s*(?P.+)$", "m"))) { // toml? + _tmp_header ~= " license: " ~ m.captures["c"]; + } else if (auto m = h_.match(regex(r"^\s+licen[cs]e(?:\s*\s*(?P.+)|$)", "m"))) { // toml markup + _tmp_header ~= " license: " ~ "\"" ~ m.captures["c"] ~ "\""; + } else if (auto m = h_.match(regex(r"^\s+licen[cs]e(?:\s+(?P.+)|\s+\\$)", "m"))) { // sdlang markup + _tmp_header ~= " license: " ~ "\"" ~ m.captures["c"] ~ "\""; + } + } + } + if (_tmp_header.length > 0) { + munged_header ~= _tmp_header; + } else { + munged_header ~= h_; + } + } + writeln(munged_header); + foreach (paragraph; paragraphs) { /+ loop to gather binary endnotes +/ + if ( !( type["curly_code"] == 1 || type["tic_code"] == 1) + && paragraph.match(rgx_endnote) + ) { + munged_endnotes ~= replaceAll!(m => m[1]) + (paragraph, rgx_endnote); + } else { + if ( type["curly_code"] == 1 || type["tic_code"] == 1 + || paragraph.matchFirst(block_curly_code_open) + || paragraph.matchFirst(block_tic_code_open) + ) { /+ code blocks identified, no munging +/ + if ( type["curly_code"] == 1 + && paragraph.matchFirst(block_curly_code_close) + ) { + type["curly_code"] = 0; + } else if (type["tic_code"] == 1 + && paragraph.matchFirst(block_tic_close) + ) { + type["tic_code"] = 0; + } else if (paragraph.matchFirst(block_curly_code_open)) { + type["curly_code"] = 1; + } else if (paragraph.matchFirst(block_tic_code_open)) { + type["tic_code"] = 1; + } + munged_contents ~= paragraph; + } else { /+ regular content, not a code block +/ + if (auto m = paragraph.matchAll(rgx_endnote_ref)) { + foreach (n; m) { + endnote_ref_count++; // endnote_refs ~= (n.captures[1]); + } + } + paragraph = replaceAll!(m => " \\\\ " ) + (paragraph, regex(r"\s*<(?:/\s*|:)?br>\s*")); // (paragraph, regex(r"(
)")); + munged_contents ~= paragraph; + } + } + } + { + import std.outbuffer; + auto buffer = new OutBuffer(); + foreach (header; munged_header) { /+ loop to inline endnotes +/ + buffer.write(header ~ "\n\n"); + } + if (munged_endnotes.length == endnote_ref_count) { + int endnote_count = -1; + foreach (content; munged_contents) { /+ loop to inline endnotes +/ + content = replaceAll!(m => "~{ " ~ munged_endnotes[++endnote_count] ~ " }~" ~ m["tail"] ) + (content, rgx_endnote_ref); // endnote_ref cannot occur in a code block or else fail + buffer.write(content ~ "\n\n"); + } + if (buffer) { + try { + string dir_out = "converted_output_"; + string path_and_file_out = dir_out ~ "/" ~ filename; + dir_out.mkdirRecurse; + auto f = File(path_and_file_out, "w"); + f.write(buffer); + // writeln("wrote: ", path_and_file_out); + } catch (FileException ex) { + writeln("did not write file"); + // Handle errors + } + } + } else { + foreach (content; munged_contents) { /+ loop to inline endnotes +/ + buffer.write(content ~ "\n\n"); + } + } + } + } catch (ErrnoException ex) { + switch(ex.errno) { + case EPERM: + case EACCES: // Permission denied + break; + case ENOENT: // File does not exist + break; + default: // Handle other errors + break; + } + } + } + } +} diff --git a/misc/util/d/tools/markup_conversion/markup_conversion_from_sisu_ruby_to_sisu_spine.d b/misc/util/d/tools/markup_conversion/markup_conversion_from_sisu_ruby_to_sisu_spine.d new file mode 100755 index 0000000..94e8718 --- /dev/null +++ b/misc/util/d/tools/markup_conversion/markup_conversion_from_sisu_ruby_to_sisu_spine.d @@ -0,0 +1,354 @@ +#!/usr/bin/env rdmd +/+ + - read in file .sst .ssi .ssm + - loop twice + - first + - check for and skip code blocks + - use unique code marker for endnote markers in text and give an endnote + number ★1, increment + - extract all endnotes in array + - second + - check that the footnote marker number count matches the number of notes + in the array + - if they match either: + - substitute each endnote marker with the array footnote[number-1] + - substitute each endnote marker with footnote + as inlined footnote markup (footnote number not needed) + - if they do not match exit + - check whether changes have been made + - if so write file with inline footnotes in sub-directory converted_output_/ + using the same name as the original file + - else, exit ++/ +import std.stdio; +import std.file; +import std.array : split, join; +import std.exception; +// import std.range; +import core.stdc.errno; +import std.regex; +import std.format; +import std.conv; +void main(string[] args) { + static heading_a = ctRegex!(`^:?[A][~] `, "m"); + static comment = ctRegex!(`^%+ `); + static block_tic_code_open = ctRegex!("^`{3} code(?:[.](?P[a-z][0-9a-z#+_]+))?(?:[(](?P[ a-zA-Z0-9;:,]*)[)])?"); + static block_tic_close = ctRegex!("^(`{3})$","m"); + static block_curly_code_open = ctRegex!(`^(?:code(?:[.](?P[a-z][0-9a-z_]+))?(?:[(](?P[ a-zA-Z0-9;:,]*)[)])?[{][ ]*$)`); + static block_curly_code_close = ctRegex!(`^([}]code)`); + auto rgx_endnote_ref = ctRegex!(`([~]\^)(?P[)\]]? |$)`, "gm"); + auto rgx_endnote = ctRegex!(`^\^~\s+(.+|\n)`, "gm"); + char[][] header0Content1(in string src_text) { // cast(char[]) + /+ split string on _first_ match of "^:?A~\s" into [header, content] array/tuple +/ + char[][] header_and_content; + auto m = (cast(char[]) src_text).matchFirst(heading_a); + header_and_content ~= m.pre; + header_and_content ~= m.hit ~ m.post; + assert(header_and_content.length == 2, + "document markup is broken, header body split == " + ~ header_and_content.length.to!string + ~ "; (header / body array split should == 2 (split is on level A~))" + ); + return header_and_content; + } + string format_body_string(string s) { + string o; + o = s + .replaceAll(regex("^<(?:/[ ]*)?br>[ ]*"), " \\\\ ") + .replaceAll(regex("[ ]*<(?:/[ ]*)?br>$"), " \\\\") + .replaceAll(regex("[ ]*<(?:/[ ]*)?br>[ ]*"), " \\\\ "); + return o; + } + string format_header_string(string s) { + string o; + o = s + .replaceAll(regex("\""), "\\\"") + .replaceAll(regex("[ ]*<(?:/[ ]*)?br>$"), " \\\\") + .replaceAll(regex("[ ]*<(?:/[ ]*)?br>[ ]*"), " \\\\ "); + return o; + } + string format_main_header(string hm, string hs = "", string c = "") { + string o; + if (c.length == 0) { + o ~= hm ~ ":\n"; + } else { + o ~= hm ~ ":\n" + ~ " " ~ hs ~ ": " + ~ "\"" ~ format_header_string(c) ~ "\"\n"; + } + return o; + } + string format_sub_header(string hs, string c) { + string o; + o ~= " " ~ hs ~ ": " + ~ "\"" ~ format_header_string(c) ~ "\"\n"; + return o; + } + foreach(arg; args[1..$]) { + if ( + !(arg.match(regex(r"--\w+"))) + && arg.match(regex(r"\w+?\.ss[itm]")) + ) { + writeln(arg); + string filename = arg; + try { + string[] munged_header, munged_contents, munged_endnotes, endnote_refs; + string text = filename.readText; + char[][] hc = header0Content1(text); + char[] src_header = hc[0]; + string[] headers = src_header.to!string.split("\n\n"); + char[] src_txt = hc[1]; + string[] paragraphs = src_txt.to!string.split("\n\n"); + int endnote_ref_count = 0; + int[string] type = [ + "curly_code" : 0, + "tic_code" : 0, + ]; + string _tmp_header; + headers[0] = headers[0].replaceFirst(regex(r"^%\s+SiSU.+", "i"), "# SiSU 8.0 spine (auto-conversion)"); + foreach (h_; headers) { + _tmp_header = ""; + if (auto m = h_.match(regex(r"^%\s*", "m"))) { + h_ = h_.replaceAll(regex(r"^%\s*", "m"), "# ") ~ "\n"; + } + if (h_.match(regex(r"^@title:|@subtitle"))) { + if (auto m = h_.match(regex(r"^@(?Ptitle):(?:[ ]+(?P.+)|\n)"))) { + _tmp_header ~= format_main_header(m.captures["h"], "main", m.captures["c"]); + } + if (auto m = h_.match(regex(r"^@(?Psubtitle):(?:[ ]+(?P.+)|$)"))) { + if (m.captures["c"].length == 0) { + } else { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + } + if (auto m = h_.match(regex(r"^\s+:(?Pmain):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:sub(?:title)?:(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header("subtitle", m.captures["c"]); + } + } else if (h_.match(regex(r"^@creator:|@author:"))) { + if (auto m = h_.match(regex(r"^(?:@creator:|@author:)(?:[ ]+(?P.+)|\n)"))) { + _tmp_header ~= format_main_header("creator", "author", m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pauthor):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + } else if (h_.match(regex(r"^@rights:"))) { + if (auto m = h_.match(regex(r"^@(?Prights):(?:[ ]+(?P.+)|\n)"))) { + _tmp_header ~= format_main_header(m.captures["h"], "copyright", m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pcopyright):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:licen[cs]e:(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header("license", m.captures["c"]); + } + } else if (h_.match(regex(r"^@date:|@date\."))) { + if (auto m = h_.match(regex(r"^@(?Pdate):(?:[ ]+(?P.+)|\n)"))) { + _tmp_header ~= format_main_header(m.captures["h"], "published", m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Ppublished):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pavailable):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pmodified):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pcreated):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pissued):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pvalid):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^@date\.(?Pavailable):[ ]+(?P.+)$"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^@date\.(?Pmodified):[ ]+(?P.+)$"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^@date\.(?Pcreated):[ ]+(?P.+)$"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^@date\.(?Pissued):[ ]+(?P.+)$"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^@date\.(?Pvalid):[ ]+(?P.+)$"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + } else if (h_.match(regex(r"^@classify:"))) { + if (auto m = h_.match(regex(r"^@classify:"))) { + _tmp_header ~= "classify:\n"; + } + if (auto m = h_.match(regex(r"^\s+:(?Ptopic_register):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:type:(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= "# type: " ~ "\"" ~ m.captures["c"] ~ "\"\n"; + } + } else if (h_.match(regex(r"^(?:@identifier:|@identify:)"))) { + if (auto m = h_.match(regex(r"^(?:@identifier:|@idenfify)"))) { + _tmp_header ~= "identify:\n"; + } + if (auto m = h_.match(regex(r"^\s+:(?Poclc):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pisbn):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pdewey):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + } else if (h_.match(regex(r"^@publisher:"))) { + if (auto m = h_.match(regex(r"^@publisher:[ ]+(?P.+)$"))) { + _tmp_header ~= "publisher: " ~ "\"" ~ m.captures["c"] ~ "\"\n"; + } + } else if (h_.match(regex(r"^@make:"))) { + // writeln(h_); + if (auto m = h_.match(regex(r"^@make:"))) { + _tmp_header ~= "make:\n"; + } + if (auto m = h_.match(regex(r"^\s+:(?Pbreaks):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pnum_top):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pheadings):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pitalics):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pbold):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pemphasis):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Ptexpdf_font):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Phome_button_text):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Phome_button_image):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pcover_image):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pfooter):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + // writeln(_tmp_header); + } else if (h_.match(regex(r"^@\w+:"))) { + _tmp_header ~= "# " ~ h_.split("\n").join("\n# ") ~ "\n"; + } else if (h_.match(regex(r"^\s+:\w+:", "m"))) { + if (auto m = h_.match(regex(r"^(?P\s+:\w+:.*)"))) { + _tmp_header ~= "# " ~ m.captures["g"] ~ "\n"; + } + } + if (h_.match(regex(r"^#", "m"))) { + if (auto m = h_.match(regex(r"^(?P#.*)", "m"))) { + _tmp_header ~= m.captures["g"] ~ "\n"; + } + } + if (_tmp_header.length > 0) { + munged_header ~= _tmp_header.split("\n\n"); + } else if (h_.length > 0) { + writeln("munging required: ", h_); + h_ = h_.replaceAll((regex(r"\n\n\n+", "m")), "\n\n"); + munged_header ~= h_; + } + } + // writeln(munged_header.join("\n")); + foreach (paragraph; paragraphs) { /+ loop to gather binary endnotes +/ + if ( !( type["curly_code"] == 1 || type["tic_code"] == 1) + && paragraph.match(rgx_endnote) + ) { + munged_endnotes ~= replaceAll!(m => m[1]) + (paragraph, rgx_endnote); + } else { + if ( type["curly_code"] == 1 || type["tic_code"] == 1 + || paragraph.matchFirst(block_curly_code_open) + || paragraph.matchFirst(block_tic_code_open) + ) { /+ code blocks identified, no munging +/ + if ( type["curly_code"] == 1 + && paragraph.matchFirst(block_curly_code_close) + ) { + type["curly_code"] = 0; + } else if (type["tic_code"] == 1 + && paragraph.matchFirst(block_tic_close) + ) { + type["tic_code"] = 0; + } else if (paragraph.matchFirst(block_curly_code_open)) { + type["curly_code"] = 1; + } else if (paragraph.matchFirst(block_tic_code_open)) { + type["tic_code"] = 1; + } + munged_contents ~= paragraph; + } else { /+ regular content, not a code block +/ + if (auto m = paragraph.matchAll(rgx_endnote_ref)) { + foreach (n; m) { + endnote_ref_count++; // endnote_refs ~= (n.captures[1]); + } + } + paragraph = format_body_string(paragraph); + // paragraph = replaceAll!(m => " \\\\ " ) + // (paragraph, regex(r"\s*<(?:/\s*|:)?br>\s*")); // (paragraph, regex(r"(
)")); + munged_contents ~= paragraph; + } + } + } + { + import std.outbuffer; + auto buffer = new OutBuffer(); + foreach (header; munged_header) { /+ loop to inline endnotes +/ + buffer.write(header ~ "\n"); + } + if (munged_endnotes.length == endnote_ref_count) { + int endnote_count = -1; + foreach (content; munged_contents) { /+ loop to inline endnotes +/ + content = replaceAll!(m => "~{ " ~ munged_endnotes[++endnote_count] ~ " }~" ~ m["tail"] ) + (content, rgx_endnote_ref); // endnote_ref cannot occur in a code block or else fail + buffer.write(content ~ "\n\n"); + } + if (buffer) { + try { + string dir_out = "converted_output_"; + string path_and_file_out = dir_out ~ "/" ~ filename; + dir_out.mkdirRecurse; + auto f = File(path_and_file_out, "w"); + f.write(buffer); + // writeln("wrote: ", path_and_file_out); + } catch (FileException ex) { + writeln("did not write file"); + // Handle errors + } + } + } else { + foreach (content; munged_contents) { /+ loop to inline endnotes +/ + buffer.write(content ~ "\n\n"); + } + } + } + } catch (ErrnoException ex) { + switch(ex.errno) { + case EPERM: + case EACCES: // Permission denied + break; + case ENOENT: // File does not exist + break; + default: // Handle other errors + break; + } + } + } + } +} diff --git a/org/spine_build_scaffold.org b/org/spine_build_scaffold.org index 144a82c..8842f52 100644 --- a/org/spine_build_scaffold.org +++ b/org/spine_build_scaffold.org @@ -371,7 +371,8 @@ skel: mkdir -p build; \ mkdir -p views; \ mkdir -p data; \ - mkdir -p misc/util; \ + mkdir -p misc/util/d/cgi/search/cgi-bin/src; \ + mkdir -p misc/util/d/tools/markup_conversion; \ mkdir -p misc/editor-syntax-etc/emacs; \ mkdir -p misc/editor-syntax-etc/vim/syntax; \ mkdir -p misc/editor-syntax-etc/vim/colors; \ @@ -405,7 +406,8 @@ expunge: distclean: expunge distclean_and_init: expunge mkdir -p views; \ - mkdir -p misc/util; \ + mkdir -p misc/util/d/cgi/search/cgi-bin/src; \ + mkdir -p misc/util/d/tools/markup_conversion; \ mkdir -p misc/editor-syntax-etc/emacs; \ mkdir -p misc/editor-syntax-etc/vim/syntax; \ mkdir -p misc/editor-syntax-etc/vim/colors; \ @@ -1151,10 +1153,6 @@ spine_exe = executable('spine', !org !misc !misc/** -!util -!util/** -!editor-syntax-etc -!editor-syntax-etc/** !ext_lib !ext_lib/** !src diff --git a/org/spine_syntax_highlighting_emacs.org b/org/spine_syntax_highlighting_emacs.org deleted file mode 100644 index 0007e48..0000000 --- a/org/spine_syntax_highlighting_emacs.org +++ /dev/null @@ -1,539 +0,0 @@ --*- mode: org -*- -#+TITLE: spine (doc_reform) information files -#+DESCRIPTION: documents - structuring, various output representations & search -#+FILETAGS: :spine:info: -#+AUTHOR: Ralph Amissah -#+EMAIL: [[mailto:ralph.amissah@gmail.com][ralph.amissah@gmail.com]] -#+COPYRIGHT: Copyright (C) 2015 - 2020 Ralph Amissah -#+LANGUAGE: en -#+STARTUP: content hideblocks hidestars noindent entitiespretty -#+PROPERTY: header-args :exports code -#+PROPERTY: header-args+ :noweb yes -#+PROPERTY: header-args+ :eval no -#+PROPERTY: header-args+ :results no -#+PROPERTY: header-args+ :cache no -#+PROPERTY: header-args+ :padline no - -* Emacs Syntax highlighting - -** README - -#+BEGIN_SRC elisp :tangle "../misc/editor-syntax-etc/emacs/README" -; put this into your .emacs file, then use the mode file: - -(load-file "~/emacs/el/sisu-spine-mode.el") -(add-to-list 'auto-mode-alist '("\\.sst$" . sisu-spine-mode)) -#+END_SRC - -** autoload sisuspine-mode-autoloads.el - -#+BEGIN_SRC elisp :tangle "../misc/editor-syntax-etc/emacs/sisu-spine-mode-autoloads.el" -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) -(autoload 'sisu-spine-mode "sisu-spine-mode" "\ -Major mode for editing SiSU (spine) markup files. -SiSU (http://www.sisudoc.org/) document structuring, publishing -and search. - -\(fn)" t nil) -(add-to-list 'auto-mode-alist '("\\.sst\\'" . sisu-spine-mode)) -(add-to-list 'auto-mode-alist '("\\.ssm\\'" . sisu-spine-mode)) -(add-to-list 'auto-mode-alist '("\\.ssi\\'" . sisu-spine-mode)) -#+END_SRC - -** mode sisu-spine-mode.el - -#+BEGIN_SRC elisp :tangle "../misc/editor-syntax-etc/emacs/sisu-spine-mode.el" -;;; sisu-spine-mode.el --- Major mode for SiSU (spine parser) markup text - -;; Copyright (C) 2011, 2020 Free Software Foundation, Inc. - -;; Author: Ralph Amissah & Ambrose Kofi Laing -;; Maintainer: Ralph Amissah -;; Keywords: text, syntax, processes, tools -;; Version: 8.0.0 -;; URL: http://www.sisudoc.org/ -;; originally looked at (based on) doc-mode, with kind permission of the author -;; Author: SUN, Tong , (c)2001-6, all right reserved -;; Version: $Date: 2006/01/19 03:13:41 $ $Revision: 1.14 $ -;; Home URL: http://xpt.sourceforge.net/ -;; with contributions from Kevin Ryde and Stefan Monnier - -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 3, or (at your option) -;; any later version. -;; -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. -;; -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - -;; Viva Software Libre! -;; Support the free software movement! -;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -;;; Commentary: - -;; SiSU (http://www.sisudoc.org/) is a document structuring and -;; publishing framework. This package provides an Emacs major mode -;; for SiSU markup, as used by the spine parser (in D) which has a different -;; header (based on yaml) from the original sisu parser (in Ruby) which has -;; bespoke headers. - -;; When this package is installed, files ending in ".sst" are automatically -;; associated with sisu-spine-mode. If a file doesn't have a -;; .sst extension, add a first line: -;; # -*- sisuSpine -*- - -;; The documentation for the "Structure Of The Hierarchy Text" can be -;; found in the sisustring for the sisu-spine-mode function. - -;;; Code: - -;; Variables: - -(defgroup sisu-faces nil - "AsciiSisu highlighting" - :group 'sisus) - -;; == Colors -; color n is more prominent than color n+1 - -(defface sisu-title-1-face - `((((class color) - (background dark)) - (:foreground "brown3" :bold t :height 1.2 :inherit variable-pitch)) - (((class color) - (background light)) - (:foreground "brown3" :bold t :height 1.2 :inherit variable-pitch)) - (t (:weight bold :inherit variable-pitch))) - "Face for AsciiSisu titles at level 1." - :group 'sisu-faces) - -(defface sisu-title-2-face - `((((class color) - (background dark)) - (:foreground "yellow4" :bold t :height 1.1 :inherit variable-pitch)) - (((class color) - (background light)) - (:foreground "yellow4" :bold t :height 1.1 :inherit variable-pitch)) - (t (:weight bold :inherit variable-pitch))) - "Face for AsciiSisu titles at level 2." - :group 'sisu-faces) - -(defface sisu-title-3-face - `((((class color) - (background dark)) - (:foreground "sienna3" :bold t)) - (((class color) - (background light)) - (:foreground "sienna3" :bold t)) - (t (:weight bold))) - "Face for AsciiSisu titles at level 3." - :group 'sisu-faces) - -(defface sisu-title-4-face - `((((class color) - (background dark)) - (:foreground "burlywood3")) - (((class color) - (background light)) - (:foreground "burlywood3")) - (t ())) - "Face for AsciiSisu titles at level 4." - :group 'sisu-faces) - -(defface info-node - '((((class color) (background light)) (:foreground "brown" :bold t :italic t)) - (((class color) (background dark)) (:foreground "white" :bold t :italic t)) - (t (:bold t :italic t))) - "Face for Info node names." - :group 'sisu-faces) - -(defvar sisu-title-1 'sisu-title-1-face) -(defvar sisu-title-2 'sisu-title-2-face) -(defvar sisu-title-3 'sisu-title-3-face) -(defvar sisu-title-4 'sisu-title-4-face) - -(defvar sisu-general-font-lock-red1 font-lock-warning-face) -(defvar sisu-general-font-lock-red2 font-lock-comment-face) -(defvar sisu-general-font-lock-red3 font-lock-string-face) - -(defvar sisu-general-font-lock-green1 font-lock-type-face) -(defvar sisu-general-font-lock-green2 font-lock-constant-face) - -(defvar sisu-general-font-lock-blue1 font-lock-keyword-face) -(defvar sisu-general-font-lock-blue2 font-lock-function-name-face) -(defvar sisu-general-font-lock-blue3 font-lock-builtin-face) - -(defvar sisu-general-font-lock-yellow1 font-lock-variable-name-face) -(defvar sisu-general-font-lock-yellow2 font-lock-comment-face) - -;; == sisu-spine-mode settings - -(defvar sisu-spine-mode-hook nil - "Normal hook run when entering Sisu Text mode.") - -(defvar sisu-spine-mode-abbrev-table nil - "Abbrev table in use in Sisu-spine-mode buffers.") -(define-abbrev-table 'sisu-spine-mode-abbrev-table ()) - -(defconst sisu-font-lock-keywords - (eval-when-compile - (list - ;;grouped text --------- - ;(cons "^```[ ]code\\(.\\|\n\\)+?\n```\n" 'sisu-general-font-lock-red2) - (cons "^```[ ]+code.*?$\\|^```$" 'sisu-general-font-lock-red2) - (cons "^```[ ]+table.*?$\\|^```$" 'sisu-general-font-lock-red2) - (cons "^```[ ]+group$\\|^```$" 'sisu-general-font-lock-red2) - (cons "^```[ ]+block$\\|^```$" 'sisu-general-font-lock-red2) - (cons "^```[ ]+poem$\\|^```$" 'sisu-general-font-lock-red2) - (cons "^```[ ]+alt$\\|^```$" 'sisu-general-font-lock-red2) - ;;grouped text --------- - (cons "^group{\\|^}group" 'sisu-general-font-lock-red2) - (cons "^block{\\|^}block" 'sisu-general-font-lock-red2) - (cons "^code{\\|^}code" 'sisu-general-font-lock-red2) - (cons "^poem{\\|^}poem" 'sisu-general-font-lock-red2) - (cons "^alt{\\|^}alt" 'sisu-general-font-lock-red2) - (cons "^table{.+\\|^}table" 'sisu-general-font-lock-red2) - (cons "^{table[^}]+}" 'sisu-general-font-lock-red2) - - (list - (concat - "^\`\\{3\\}[ ]+code.*?$" - "\\(.\\|\n\\)+?" - "\`\\{3\\}$" - ) - '(1 sisu-general-font-lock-red2 t) - '(2 nil t) - '(3 sisu-general-font-lock-red2 t) - ) - (list - (concat - "^\`\\{3\\}[ ]+table.*?$" - "\\(.\\|\n\\)+?" - "\`\\{3\\}$" - ) - '(1 sisu-general-font-lock-red2 t) - '(2 nil t) - '(3 sisu-general-font-lock-red2 t) - ) - (list - (concat - "^\`\\{3\\}[ ]+\\(group\\|block\\|alt\\|poem\\)$" - "\\(.\\|\n\\)+?" - "^\`\\{3\\}$" - ) - '(1 sisu-general-font-lock-red2 t) - '(2 nil t) - '(3 sisu-general-font-lock-red2 t) - ) - - ;; footnote/endnote ---- - ;(cons "\~{.+?}\~" 'sisu-general-font-lock-green1) - (cons "\~{\\*\\*\\|\~{\\*\\|\~{\\|}\~" 'sisu-general-font-lock-red2) - (cons "\~\\[\\+\\|\~\\[\\*\\|\~\\[\\|\\]\~" 'sisu-general-font-lock-red2) - (cons "\~\\^ \\|^\\^\~ " 'sisu-general-font-lock-red2) - (list - (concat - "\\(\*\~\\)" - "\\([^ \r\t\n]+\\)" - ) - '(1 sisu-general-font-lock-red1 t) - '(2 sisu-general-font-lock-blue2 t) - ) - - ;; emphasis (can be program configured to be bold italics or underscore) - (list - (concat - "\\([*]{\\)" - "\\([^}]+\\)" - "\\(}[*]\\)" - ) - '(1 sisu-general-font-lock-red1 t) - '(2 sisu-general-font-lock-red1 t) - '(3 sisu-general-font-lock-red1 t) - ) - - ;; bold ---------------- - (list - (concat - "\\([!]{\\)" - "\\([^}]+\\)" - "\\(}[!]\\)" - ) - '(1 sisu-general-font-lock-red1 t) - '(2 sisu-general-font-lock-red1 t) - '(3 sisu-general-font-lock-red1 t) - ) - (cons "\\*[^ ]+\\*" 'sisu-general-font-lock-red1) - (cons "^!_ .+" 'sisu-general-font-lock-red1) - - ;; italics ------------- - (list - (concat - "\\([/]{\\)" - "\\([^}]+\\)" - "\\(}[/]\\)" - ) - '(1 sisu-general-font-lock-red1 t) - '(2 sisu-general-font-lock-blue1 t) - '(3 sisu-general-font-lock-red1 t) - ) - - ;; underscore ---------- - (list - (concat - "\\([_]{\\)" - "\\([^}]+\\)" - "\\(\}[_]\\)" - ) - '(1 sisu-general-font-lock-red1 t) - '(2 sisu-general-font-lock-red1 t) - '(3 sisu-general-font-lock-red1 t) - ) - - ;; monospace ----------- - (list - (concat - "\\([#]{\\)" - "\\([^}]+\\)" - "\\(}[#]\\)" - ) - '(1 sisu-general-font-lock-red1 t) - '(2 sisu-general-font-lock-red1 t) - '(3 sisu-general-font-lock-red1 t) - ) - - ;; citation ------------ - (list - (concat - "\\([\"]{\\)" - "\\([^}]+\\)" - "\\(}[\"]\\)" - ) - '(1 sisu-general-font-lock-red1 t) - '(2 sisu-general-font-lock-red1 t) - '(3 sisu-general-font-lock-red1 t) - ) - - ;; inserted text ------- - (list - (concat - "\\([\+]{\\)" - "\\([^}]+\\)" - "\\(}[\+]\\)" - ) - '(1 sisu-general-font-lock-red1 t) - '(2 sisu-general-font-lock-red1 t) - '(3 sisu-general-font-lock-red1 t) - ) - - ;; strike through ------ - (list - (concat - "\\(\\-{\\)" - "\\([^}]+\\)" - "\\(}\\-\\)" - ) - '(1 sisu-general-font-lock-red1 t) - '(2 sisu-general-font-lock-red1 t) - '(3 sisu-general-font-lock-red1 t) - ) - - ;; superscript --------- - (list - (concat - "\\(\\^{\\)" - "\\([^}]+\\)" - "\\(}\\^\\)" - ) - '(1 sisu-general-font-lock-red1 t) - '(2 sisu-general-font-lock-red1 t) - '(3 sisu-general-font-lock-red1 t) - ) - - ;; subscript ----------- - (list - (concat - "\\([,]{\\)" - "\\([^}]+\\)" - "\\(}[,]\\)" - ) - '(1 sisu-general-font-lock-red1 t) - '(2 sisu-general-font-lock-red1 t) - '(3 sisu-general-font-lock-red1 t) - ) - - ;; numbered list - (cons "^# \\|^_# " 'sisu-general-font-lock-red1) - - ;; bullet text - (cons "^_\\*[1-9] \\|^_\\* " 'sisu-general-font-lock-red1) - - ;; indented text - (cons "^_[1-9] " 'sisu-general-font-lock-red1) - (cons "^_[1-9]! " 'sisu-general-font-lock-red1) - - ;; hanging indented text [proposed enable when implemented] - (cons "^__[1-9] " 'sisu-general-font-lock-red1) - (cons "^_[0-9]_[0-9] " 'sisu-general-font-lock-red1) - (cons "^__[1-9]! " 'sisu-general-font-lock-red1) - (cons "^_[0-9]_[0-9]! " 'sisu-general-font-lock-red1) - - ;; url - (cons "\\(^\\|[ ]\\)https?:[/][/][^ \t\n\r<]+" 'sisu-general-font-lock-blue2) - - ;; Comment Lines - (cons "^% .*" 'sisu-general-font-lock-blue1) - - ;; page break - (cons "^\\(-\\\\\\\\-\\|=\\\\\\\\=\\|-\\.\\.-\\)" 'sisu-general-font-lock-red2) - - ;; line break - (cons " \\\\\\\\ " 'sisu-general-font-lock-red1) - - ;; line break (depreciated) - (cons "
" 'sisu-general-font-lock-red1) - - ;; Section titles - (list "^\\(\\([1-4]\\|:?[A-D]\\)\\~\\)\\(.*\\)" - '(1 sisu-title-1 t) - '(3 sisu-title-2 t) - ) - - ;; hyper-links - (list - (concat - "\\({~^\\|{\\)" - "\\([^}{]+\\)" - "\\(}https?:[/][/][^ \r\n\t<]+\\)" - ) - '(1 sisu-general-font-lock-blue2 t) - '(2 sisu-general-font-lock-red1 t) - '(3 sisu-general-font-lock-blue2 t) - ) - - ;; book index - (list - (concat - "^\\(\={\\)" - "\\([^}{]+\\)" - "\\(}\\)$" - ) - '(1 sisu-general-font-lock-green1 t) - '(2 nil t) - '(3 sisu-general-font-lock-green1 t) - ) - - ;(cons "^\={.+}" 'sisu-general-font-lock-green1) - - ;; numbers - (cons "\\<[.0-9]+\\>" 'sisu-general-font-lock-green2) - - ;; bullets sisu_normal (nearly copied regexp) - (cons "^_\\([1-9*]\\|[1-9]\\*\\) " 'sisu-general-font-lock-blue2) - - ;; image links - (list - (concat - "\\({\\)" - "\\([^}{]+\\)" - "\\(}image\\)" - ) - '(1 sisu-general-font-lock-blue2 t) - '(2 sisu-general-font-lock-red1 t) - '(3 sisu-general-font-lock-blue2 t) - ) - - ;; insert file links - (list - (concat - "\\(<< \\)" - "\\([^ \r\t\n]+\\.ss\\)" - "\\(i\\|t\\)" - ) - '(1 sisu-general-font-lock-blue2 t) - '(2 sisu-general-font-lock-blue2 t) - '(3 sisu-general-font-lock-blue2 t) - ) - - ;; raw keywords - (list - (concat - "^\\(\\(" - "creator\\|" - "title\\|" - "date\\|" - "rights\\|" - "publisher\\|" - "classify\\|" - "identifier\\|" - "original\\|" - "notes\\|" - "links\\|" - "make\\|" - "\\):\\)\\(.*\\)" - ) - '(1 sisu-title-2 keep) - '(3 sisu-title-3 keep) - ) - ) - ) - "Default expressions to highlight in AsciiSisu mode." -) - -;; outline mode evil "folding" if available -;; (define-key evil-normal-state-map ",0" 'show-all) -;; (define-key evil-normal-state-map ",-" 'hide-body) -;; (define-key evil-normal-state-map ",+" 'show-subtree) -;; (define-key evil-normal-state-map ",=" 'show-subtree) - -;; - -;; Sisu & Autoload: - -;;;###autoload -(define-derived-mode sisu-spine-mode text-mode "SiSU" - "Major mode for editing SiSU files. -SiSU document structuring, publishing in multiple formats and search. -URL `http://www.sisudoc.org/'" - (modify-syntax-entry ?\' ".") - ;;(flyspell-mode nil) - - (make-local-variable 'paragraph-start) - (setq paragraph-start (concat "$\\|>" page-delimiter)) - (make-local-variable 'paragraph-separate) - (setq paragraph-separate paragraph-start) - (make-local-variable 'paragraph-ignore-fill-prefix) - (setq paragraph-ignore-fill-prefix t) - - (set (make-local-variable 'outline-regexp) - "^\\(\\([1-4]\\|:?[A-D]\\)\\~\\|\\@[a-z]+:\\( \\|$\\)\\)") - - (make-local-variable 'require-final-newline) - (setq require-final-newline t) - - (make-local-variable 'font-lock-defaults) - (setq font-lock-defaults - '(sisu-font-lock-keywords - nil ; KEYWORDS-ONLY: no - nil ; CASE-FOLD: no - ((?_ . "w")) ; SYNTAX-ALIST - )) - ;; Enable outlining. - ;; TODO with outlining make sure linum (line numbering) is off, - ;; else performance penalty, sucks bigtime - (outline-minor-mode 1)) - -;;;###autoload (add-to-list 'auto-mode-alist '("\\.ss[imt]\\'" . sisu-spine-mode)) - -(provide 'sisu-spine-mode) - -;; - -;;; sisu-spine-mode.el ends here -#+END_SRC diff --git a/org/spine_syntax_highlighting_vim.org b/org/spine_syntax_highlighting_vim.org deleted file mode 100644 index 137d734..0000000 --- a/org/spine_syntax_highlighting_vim.org +++ /dev/null @@ -1,984 +0,0 @@ --*- mode: org -*- -#+TITLE: spine (doc_reform) information files -#+DESCRIPTION: documents - structuring, various output representations & search -#+FILETAGS: :spine:info: -#+AUTHOR: Ralph Amissah -#+EMAIL: [[mailto:ralph.amissah@gmail.com][ralph.amissah@gmail.com]] -#+COPYRIGHT: Copyright (C) 2015 - 2020 Ralph Amissah -#+LANGUAGE: en -#+STARTUP: content hideblocks hidestars noindent entitiespretty -#+PROPERTY: header-args :exports code -#+PROPERTY: header-args+ :noweb yes -#+PROPERTY: header-args+ :eval no -#+PROPERTY: header-args+ :results no -#+PROPERTY: header-args+ :cache no -#+PROPERTY: header-args+ :padline no - -* Vim Syntax highlighting -** filetype - -#+BEGIN_SRC text :tangle "../misc/editor-syntax-etc/vim/filetype.vim" -" SiSU filetype file -if exists("did_load_filetypes") - finish -endif -augroup filetypedetect - au! BufNewFile,BufRead *.sst,*.ssm,*.ssi,*.-sst setf sisu - au! BufNewFile,BufRead *._sst,*.sst.meta,*.-sst.meta,*._sst.meta setf sisu -augroup END -#+END_SRC - -** debian vim addon manager - -#+BEGIN_SRC text :tangle "../misc/editor-syntax-etc/vim/vim-sisu.yaml" -#vim-addons: debian vim-addon-manager -addon: sisu -description: SiSU documents - structuring, publishing in multiple formats and search -basedir: /usr/share/vim-scripts/ -files: - - ftplugin/sisu.vim - - syntax/sisu.vim -#+END_SRC - -** color files -*** def.vim - -#+BEGIN_SRC text :tangle "../misc/editor-syntax-etc/vim/colors/def.vim" -" Vim color file -" Name: def -" Maintainer: Ralph Amissah -" Last Change: 2013-02-14 -" URL: -" Note: primarily 16 color cterm improved by tweaking of .Xdefaults -" (with occasional other colors selected from 256 color palate) -" .Xdefaults tweaking to make identical to def (256) provided, -" along with an alternative possibility using colors beyond -" 256 color palate -:hi clear -if exists("syntax_on") - syntax reset -endif -:set t_Co=256 -:set background=dark -:let colors_name = "def" -" ------- -" terminal def -" ------- -:hi Normal ctermbg=0 ctermfg=7 -":hi Cursor ctermbg=5 ctermfg=0 -:hi lCursor cterm=reverse -:hi StatusLine cterm=bold,reverse -:hi StatusLineNC cterm=reverse -:hi Search cterm=none ctermbg=57 ctermfg=0 -:hi IncSearch cterm=none ctermbg=154 ctermfg=0 -:hi SpecialKey ctermfg=4 -:hi Visual cterm=reverse -:hi VisualNOS cterm=bold,underline -:hi MoreMsg ctermfg=2 -:hi ModeMsg cterm=bold -:hi Question ctermfg=2 -:hi Title cterm=bold ctermfg=3 -:hi NonText cterm=bold ctermfg=4 -:hi LineNr cterm=bold ctermbg=0 ctermfg=0* -:hi CursorLineNr cterm=bold ctermbg=166 ctermfg=0 -:hi Directory ctermfg=4 -:hi WildMenu ctermbg=3 ctermfg=0 -:hi VertSplit cterm=reverse -:hi Folded cterm=none ctermbg=0 ctermfg=8 -:hi FoldColumn ctermbg=7 ctermfg=4 -:hi DiffAdd cterm=none ctermbg=2 ctermfg=0 -:hi DiffChange cterm=none ctermbg=7 ctermfg=0 -:hi DiffDelete cterm=none ctermbg=7 ctermfg=0 -:hi DiffText cterm=none ctermbg=6 ctermfg=0 -:hi String cterm=none ctermfg=3 -:hi Comment cterm=none ctermbg=0 ctermfg=4 -:hi Constant ctermfg=1 -:hi Special ctermfg=6 -:hi Identifier ctermfg=6 -:hi Statement ctermfg=2 -:hi Operator ctermfg=2 -:hi PreProc ctermfg=1 -:hi Type cterm=bold ctermfg=3 -:hi Delimiter cterm=none ctermfg=2 -:hi Ignore cterm=bold ctermfg=7 -:hi Todo ctermbg=3 ctermfg=0 -:hi Underlined cterm=underline -:hi Include ctermfg=1 -:hi Define ctermfg=3 -:hi Function ctermfg=6 -:hi Structure ctermfg=2 -:hi MatchParen cterm=bold ctermbg=4 ctermfg=7 -:hi CursorLine cterm=bold -:hi CursorColumn ctermbg=17 -:hi ColorColumn ctermbg=17 -:hi SpellBad cterm=underline ctermbg=0 ctermfg=5 -:hi SpellCap cterm=underline ctermbg=0 ctermfg=5 -:hi SpellLocal cterm=underline ctermbg=0 ctermfg=5 -:hi SpellRare cterm=underline ctermbg=0 ctermfg=5 -:hi TrailingWhitespace ctermbg=1 -:hi ExtraWhitespace ctermbg=1 -:hi WarningMsg ctermfg=1 -:hi ErrorMsg cterm=bold ctermbg=1 ctermfg=7 -:hi Error cterm=bold ctermbg=1 ctermfg=7 -" ------- -" gui def -" ------- -:hi Normal guibg=#000000 guifg=#D3D3D3 -:hi Cursor guibg=#CC9966 guifg=#000000 -:hi lCursor gui=reverse -:hi StatusLine gui=bold,reverse -:hi StatusLineNC gui=reverse -:hi Search gui=none guibg=#5F00FF guifg=#000000 -:hi IncSearch gui=none guibg=#AFFF00 guifg=#000000 -:hi SpecialKey guifg=#5971AD -:hi Visual gui=reverse -:hi VisualNOS gui=bold,underline -:hi MoreMsg guifg=#4E9A06 -:hi ModeMsg gui=bold -:hi Question guifg=#4E9A06 -:hi Title gui=bold guifg=#C4A000 -:hi NonText gui=bold guifg=#5971AD -:hi LineNr gui=bold guibg=#000000 guifg=#808080 -:hi CursorLineNr gui=bold guibg=#D75F00 guifg=#000000 -:hi Directory guifg=#5971AD -:hi WildMenu guibg=#C4A000 guifg=#000000 -:hi VertSplit gui=reverse -:hi Folded gui=none guibg=#000000 guifg=#808080 -:hi FoldColumn guibg=#D3D3D3 guifg=#5971AD -:hi DiffAdd gui=none guibg=#4E9A06 guifg=#000000 -:hi DiffChange gui=none guibg=#D3D3D3 guifg=#000000 -:hi DiffDelete gui=none guibg=#D3D3D3 guifg=#000000 -:hi DiffText gui=none guibg=#06989A guifg=#000000 -:hi String gui=none guifg=#C4A000 -:hi Comment gui=none guibg=#000000 guifg=#5971AD -:hi Constant guifg=#CC0000 -:hi Special guifg=#06989A -:hi Identifier guifg=#06989A -:hi Statement guifg=#4E9A06 -:hi Operator guifg=#4E9A06 -:hi PreProc guifg=#CC0000 -:hi Type gui=bold guifg=#C4A000 -:hi Delimiter gui=none guifg=#4E9A06 -:hi Ignore gui=bold guifg=#D3D3D3 -:hi Todo guibg=#C4A000 guifg=#000000 -:hi Underlined gui=underline -:hi Include guifg=#CC0000 -:hi Define guifg=#C4A000 -:hi Function guifg=#06989A -:hi Structure guifg=#4E9A06 -:hi MatchParen gui=bold guibg=#5971AD guifg=#D3D3D3 -:hi CursorLine gui=bold -:hi CursorColumn guibg=#00005F -:hi ColorColumn guibg=#00005F -:hi SpellBad gui=underline guibg=#000000 guifg=#75507B -:hi SpellCap gui=underline guibg=#000000 guifg=#75507B -:hi SpellLocal gui=underline guibg=#000000 guifg=#75507B -:hi SpellRare gui=underline guibg=#000000 guifg=#75507B -:hi TrailingWhitespace guibg=#080000 -:hi ExtraWhitespace guibg=#CC0000 -:hi WarningMsg guifg=#CC0000 -:hi ErrorMsg gui=bold guibg=#CC0000 guifg=#D3D3D3 -:hi Error gui=bold guibg=#CC0000 guifg=#D3D3D3 -" ------- -"256 color .Xdefaults vim: cterm giu -" -" -" ------- -" 256 color .Xdefaults vim: cterm giu def -" ------- -" 16 color standard altered 256 altered beyond 256 -" black/dark grey -" 0 [ 0:#000000] #000000 -" 8 [ 8:#808080] [59:#5F5F5F] #555555 -" red -" 1 [ 1:#800000] 160:#DF0000 #CC0000 -" 9 [ 9:#FF0000] #EF2929 -" green -" 2 [ 2:#008000] 112:#87DF00 #4E9A06 -" 10 [10:#00FF00] 154:#AFFF00 #8AE234 -" yellow/orange -" 3 [ 3:#808000] 178:#DFAF00 #C4A000 -" 11 [11:#FFFF00] 184:#DFDF00 #FC9E4F -" blue -" 4 [ 4:#000080] 24:#005F87 #5971AD -" 12 [12:#0000FF] 73:#5FAFAF #729FCF -" magenta -" 5 [ 5:#800080] 90:#870087 #75507B -" 13 [13:#FF00FF] 126:#AF0087 #AD7FA8 -" cyan -" 6 [ 6:#008080] 37:#00AFAF #06989A -" 14 [14:#00FFFF] 87:#5FFFFF #34E2E2 -" white -" 7 [ 7:#C0C0C0] #D3D3D3 -" 15 [15:#FFFFFF] #EEEEEE -" -------- -" .Xdefaults (rxvt urxvt setting beyond 256 colors, vim colorscheme "def" gui settings) -" (vim colorscheme "def" cterm matches "def" gui if .Xdefaults set thus) -" -------- -" ! black -" Rxvt.color0 : #000000 -" Rxvt.color8 : #555555 -" ! red -" Rxvt.color1 : #CC0000 -" Rxvt.color9 : #EF2929 -" ! green -" Rxvt.color2 : #4E9A06 -" Rxvt.color10 : #8AE234 -" ! yellow -" Rxvt.color3 : #C4A000 -" Rxvt.color11 : #FCE94F -" ! blue -" Rxvt.color4 : #5971AD -" Rxvt.color12 : #729FCF -" ! magenta -" Rxvt.color5 : #75507B -" Rxvt.color13 : #AD7FA8 -" ! cyan -" Rxvt.color6 : #06989A -" Rxvt.color14 : #34E2E2 -" ! white -" Rxvt.color7 : #D3D7CF -" Rxvt.color15 : #EEEEEE -" -------- -" .Xdefaults 256 (rxvt urxvt setting, vim colorscheme "def256" cterm & gui settings) -" (vim colorscheme "def" cterm matches "def256" if .Xdefaults set thus) -" -------- -" ! black -" Rxvt.color0 : #000000 -" Rxvt.color8 : #808080 -" ! red -" Rxvt.color1 : #DF0000 -" Rxvt.color9 : #FF0000 -" ! green -" Rxvt.color2 : #87DF00 -" Rxvt.color10 : #AFFF00 -" ! yellow -" Rxvt.color3 : #DFAF00 -" Rxvt.color11 : #FFFF00 -" ! blue -" Rxvt.color4 : #5F87DF -" Rxvt.color12 : #87DFFF -" ! magenta -" Rxvt.color5 : #8700DF -" Rxvt.color13 : #87DFFF -" ! cyan -" Rxvt.color6 : #00DFDF -" Rxvt.color14 : #5F5FDF -" ! white -" Rxvt.color7 : #C0C0C0 -" Rxvt.color15 : #FFFFFF -#+END_SRC - -*** slate.vim - -#+BEGIN_SRC text :tangle "../misc/editor-syntax-etc/vim/colors/slate.vim" -"%% SiSU Vim color file -" Name: Slate -" Maintainer: Ralph Amissah -" Last Change: 2013-02-09 -" URL: -" Notes: cterm now uses frugal-sisu 8 colors for term -" (for gui originally looked at desert Hans Fugal -" (April/May 2003)) -:set background=dark -:hi clear -if exists("syntax_on") - syntax reset -endif -:let colors_name = "slate" -" 0 = black, 1 = red, 2 = green, 3 = yellow/orange, 4 = blue, 5 = magenta, 6 = cyan, 7 = white -:hi Normal ctermbg=0 ctermfg=7 guibg=grey15 guifg=white -:hi Cursor term=reverse cterm=reverse guibg=khaki guifg=slategrey -:hi lCursor term=reverse cterm=reverse -:hi StatusLine term=reverse cterm=bold,reverse gui=none guibg=#c2bfa5 guifg=black -:hi StatusLineNC term=reverse cterm=reverse gui=none guibg=#c2bfa5 guifg=grey40 -:hi Search term=reverse cterm=none ctermbg=2 ctermfg=0 guibg=peru guifg=wheat -:hi IncSearch term=reverse cterm=bold ctermbg=2 ctermfg=7 guibg=black guifg=green -:hi SpecialKey term=bold ctermfg=4 guifg=yellowgreen -:hi Visual term=reverse cterm=reverse gui=none guibg=olivedrab guifg=khaki -:hi VisualNOS term=bold,underline cterm=bold,underline -:hi MoreMsg term=bold ctermfg=2 guifg=SeaGreen -:hi ModeMsg term=bold cterm=bold guifg=goldenrod -:hi Question term=standout ctermfg=2 guifg=springgreen -:hi Title term=bold cterm=bold ctermfg=3 gui=bold guifg=gold -:hi NonText term=bold cterm=bold ctermfg=4 guibg=grey15 guifg=RoyalBlue -:hi LineNr term=underline cterm=bold ctermbg=0 ctermfg=0* guifg=grey50 -:hi Directory term=bold ctermfg=4 -:hi WildMenu term=standout ctermbg=3 ctermfg=0 guibg=darkyellow guifg=black -:hi VertSplit term=reverse cterm=reverse gui=none guibg=#c2bfa5 guifg=grey40 -:hi Folded term=standout cterm=none ctermbg=0 ctermfg=7 guibg=black guifg=grey40 -:hi FoldColumn term=standout ctermbg=7 ctermfg=4 guibg=black guifg=grey20 -:hi DiffChange cterm=none ctermbg=7 ctermfg=0 guibg=darkgrey guifg=white -:hi DiffText cterm=none ctermbg=6 ctermfg=0 guibg=darkcyan guifg=white -:hi DiffAdd cterm=none ctermbg=2 ctermfg=0 guibg=darkgreen guifg=white -:hi DiffDelete cterm=none ctermbg=7 ctermfg=0 guibg=darkgrey guifg=black -:hi String cterm=none ctermfg=3 guifg=SkyBlue -:hi Comment term=bold cterm=none ctermbg=0 ctermfg=7 guifg=grey40 -:hi Constant term=underline ctermfg=1 guifg=#ffa0a0 -:hi Special term=bold ctermfg=6 guifg=darkkhaki -:hi Identifier term=underline ctermfg=6 guifg=salmon -:hi Statement term=bold ctermfg=6 guifg=CornflowerBlue -:hi Operator term=bold ctermfg=1 guifg=red -:hi PreProc term=underline ctermbg=7 ctermfg=1 guibg=white guifg=red -:hi Type term=underline ctermfg=2 guifg=CornflowerBlue -:hi Delimiter term=none cterm=none ctermfg=1 -:hi Ignore cterm=bold ctermfg=7 guifg=grey40 -:hi Todo term=standout ctermbg=3 ctermfg=0 guibg=yellow2 guifg=orangered -:hi Underlined term=underline cterm=underline -:hi Include ctermfg=1 guifg=red -:hi Define ctermfg=3 gui=bold guifg=gold -:hi Function ctermfg=6 guifg=navajowhite -:hi Structure ctermfg=2 guifg=green -:hi MatchParen cterm=bold ctermbg=4 ctermfg=7 -:hi CursorLine cterm=bold,underline guibg=black -:hi CursorColumn cterm=bold guibg=black -:hi SpellBad term=underline,standout cterm=none ctermbg=7 ctermfg=0 guibg=darkmagenta guifg=white -:hi SpellCap term=underline,standout cterm=none ctermbg=7 ctermfg=0 -:hi SpellLocal term=underline,standout cterm=none ctermbg=7 ctermfg=0 guibg=darkmagenta guifg=white -:hi SpellRare term=underline,standout cterm=none ctermbg=7 ctermfg=0 -:hi WarningMsg term=standout ctermfg=1 guibg=darkmagenta guifg=salmon -:hi ErrorMsg term=standout cterm=bold ctermbg=1 ctermfg=7 guibg=darkmagenta guifg=white -:hi Error term=reverse cterm=bold ctermbg=1 ctermfg=7 guibg=darkmagenta guifg=white -:hi Black ctermbg=grey ctermfg=black guibg=grey guifg=black -:hi Red ctermbg=black ctermfg=red guibg=black guifg=red -:hi Magenta ctermbg=black ctermfg=magenta guibg=black guifg=magenta -:hi Blue ctermbg=black ctermfg=blue guibg=black guifg=blue -:hi Cyan ctermbg=black ctermfg=cyan guibg=black guifg=cyan -:hi Green ctermbg=black ctermfg=green guibg=black guifg=green -:hi Yellow ctermbg=black ctermfg=yellow guibg=black guifg=yellow -:hi White ctermbg=black ctermfg=white guibg=black guifg=white -#+END_SRC - -*** def-sisu.vim - -#+BEGIN_SRC text :tangle "../misc/editor-syntax-etc/vim/colors/def-sisu.vim" -" Vim color file -" Name: def-sisu -" Maintainer: Ralph Amissah -" Last Change: 2013-02-14 -" URL: -" Note: primarily 16 color cterm improved by tweaking of .Xdefaults -" (with occasional other colors selected from 256 color palate) -" .Xdefaults tweaking to make identical to def (256) provided, -" along with an alternative possibility using colors beyond -" 256 color palate -:hi clear -if exists("syntax_on") - syntax reset -endif -:set t_Co=256 -:set background=dark -:let colors_name = "def-sisu" -" ------- -" terminal def -" ------- -:hi Normal ctermbg=0 ctermfg=7 -":hi Cursor ctermbg=5 ctermfg=0 -:hi lCursor cterm=reverse -:hi StatusLine cterm=bold,reverse -:hi StatusLineNC cterm=reverse -:hi Search cterm=none ctermbg=57 ctermfg=0 -:hi IncSearch cterm=none ctermbg=154 ctermfg=0 -:hi SpecialKey ctermfg=4 -:hi Visual cterm=reverse -:hi VisualNOS cterm=bold,underline -:hi MoreMsg ctermfg=2 -:hi ModeMsg cterm=bold -:hi Question ctermfg=2 -:hi Title cterm=bold ctermfg=3 -:hi NonText cterm=bold ctermfg=4 -:hi LineNr cterm=bold ctermbg=0 ctermfg=0* -:hi CursorLineNr cterm=bold ctermbg=166 ctermfg=0 -:hi Directory ctermfg=4 -:hi WildMenu ctermbg=3 ctermfg=0 -:hi VertSplit cterm=reverse -:hi Folded cterm=none ctermbg=0 ctermfg=8 -:hi FoldColumn ctermbg=7 ctermfg=4 -:hi DiffAdd cterm=none ctermbg=2 ctermfg=0 -:hi DiffChange cterm=none ctermbg=7 ctermfg=0 -:hi DiffDelete cterm=none ctermbg=7 ctermfg=0 -:hi DiffText cterm=none ctermbg=6 ctermfg=0 -:hi String cterm=none ctermfg=3 -:hi Comment cterm=none ctermbg=0 ctermfg=4 -:hi Constant ctermfg=1 -:hi Special ctermfg=6 -:hi Identifier ctermfg=6 -:hi Statement ctermfg=6 -:hi Operator ctermfg=1 -:hi PreProc ctermbg=7 ctermfg=1 -:hi Type ctermfg=2 -:hi Delimiter cterm=none ctermfg=1 -:hi Ignore cterm=bold ctermfg=7 -:hi Todo ctermbg=3 ctermfg=0 -:hi Underlined cterm=underline -:hi Include ctermfg=1 -:hi Define ctermfg=3 -:hi Function ctermfg=6 -:hi Structure ctermfg=2 -:hi MatchParen cterm=bold ctermbg=4 ctermfg=7 -:hi CursorLine cterm=bold -:hi CursorColumn ctermbg=17 -:hi ColorColumn ctermbg=17 -:hi SpellBad cterm=underline ctermbg=0 ctermfg=5 -:hi SpellCap cterm=underline ctermbg=0 ctermfg=5 -:hi SpellLocal cterm=underline ctermbg=0 ctermfg=5 -:hi SpellRare cterm=underline ctermbg=0 ctermfg=5 -:hi TrailingWhitespace ctermbg=1 -:hi ExtraWhitespace ctermbg=1 -:hi WarningMsg ctermfg=1 -:hi ErrorMsg cterm=bold ctermbg=1 ctermfg=7 -:hi Error cterm=bold ctermbg=1 ctermfg=7 -" ------- -" gui def -" ------- -:hi Normal guibg=#000000 guifg=#D3D3D3 -:hi Cursor guibg=#CC9966 guifg=#000000 -:hi lCursor gui=reverse -:hi StatusLine gui=bold,reverse -:hi StatusLineNC gui=reverse -:hi Search gui=none guibg=#5F00FF guifg=#000000 -:hi IncSearch gui=none guibg=#AFFF00 guifg=#000000 -:hi SpecialKey guifg=#5971AD -:hi Visual gui=reverse -:hi VisualNOS gui=bold,underline -:hi MoreMsg guifg=#4E9A06 -:hi ModeMsg gui=bold -:hi Question guifg=#4E9A06 -:hi Title gui=bold guifg=#C4A000 -:hi NonText gui=bold guifg=#5971AD -:hi LineNr gui=bold guibg=#000000 guifg=#808080 -:hi CursorLineNr gui=bold guibg=#D75F00 guifg=#000000 -:hi Directory guifg=#5971AD -:hi WildMenu guibg=#C4A000 guifg=#000000 -:hi VertSplit gui=reverse -:hi Folded gui=none guibg=#000000 guifg=#808080 -:hi FoldColumn guibg=#D3D3D3 guifg=#5971AD -:hi DiffAdd gui=none guibg=#4E9A06 guifg=#000000 -:hi DiffChange gui=none guibg=#D3D3D3 guifg=#000000 -:hi DiffDelete gui=none guibg=#D3D3D3 guifg=#000000 -:hi DiffText gui=none guibg=#06989A guifg=#000000 -:hi String gui=none guifg=#C4A000 -:hi Comment gui=none guibg=#000000 guifg=#5971AD -:hi Constant guifg=#CC0000 -:hi Special guifg=#06989A -:hi Identifier guifg=#06989A -:hi Statement guifg=#06989A -:hi Operator guifg=#CC0000 -:hi PreProc guibg=#D3D3D3 guifg=#CC0000 -:hi Type guifg=#4E9A06 -:hi Delimiter gui=none guifg=#CC0000 -:hi Ignore gui=bold guifg=#D3D3D3 -:hi Todo guibg=#C4A000 guifg=#000000 -:hi Underlined gui=underline -:hi Include guifg=#CC0000 -:hi Define guifg=#C4A000 -:hi Function guifg=#06989A -:hi Structure guifg=#4E9A06 -:hi MatchParen gui=bold guibg=#5971AD guifg=#D3D3D3 -:hi CursorLine gui=bold -:hi CursorColumn guibg=#00005F -:hi ColorColumn guibg=#00005F -:hi SpellBad gui=underline guibg=#000000 guifg=#75507B -:hi SpellCap gui=underline guibg=#000000 guifg=#75507B -:hi SpellLocal gui=underline guibg=#000000 guifg=#75507B -:hi SpellRare gui=underline guibg=#000000 guifg=#75507B -:hi TrailingWhitespace guibg=#080000 -:hi ExtraWhitespace guibg=#CC0000 -:hi WarningMsg guifg=#CC0000 -:hi ErrorMsg gui=bold guibg=#CC0000 guifg=#D3D3D3 -:hi Error gui=bold guibg=#CC0000 guifg=#D3D3D3 -" ------- -"256 color .Xdefaults vim: cterm giu -" -" -" ------- -" 256 color .Xdefaults vim: cterm giu def -" ------- -" 16 color standard altered 256 altered beyond 256 -" black/dark grey -" 0 [ 0:#000000] #000000 -" 8 [ 8:#808080] [59:#5F5F5F] #555555 -" red -" 1 [ 1:#800000] 160:#DF0000 #CC0000 -" 9 [ 9:#FF0000] #EF2929 -" green -" 2 [ 2:#008000] 112:#87DF00 #4E9A06 -" 10 [10:#00FF00] 154:#AFFF00 #8AE234 -" yellow/orange -" 3 [ 3:#808000] 178:#DFAF00 #C4A000 -" 11 [11:#FFFF00] 184:#DFDF00 #FC9E4F -" blue -" 4 [ 4:#000080] 24:#005F87 #5971AD -" 12 [12:#0000FF] 73:#5FAFAF #729FCF -" magenta -" 5 [ 5:#800080] 90:#870087 #75507B -" 13 [13:#FF00FF] 126:#AF0087 #AD7FA8 -" cyan -" 6 [ 6:#008080] 37:#00AFAF #06989A -" 14 [14:#00FFFF] 87:#5FFFFF #34E2E2 -" white -" 7 [ 7:#C0C0C0] #D3D3D3 -" 15 [15:#FFFFFF] #EEEEEE -" -------- -" .Xdefaults (rxvt urxvt setting beyond 256 colors, vim colorscheme "def" gui settings) -" (vim colorscheme "def" cterm matches "def" gui if .Xdefaults set thus) -" -------- -" ! black -" Rxvt.color0 : #000000 -" Rxvt.color8 : #555555 -" ! red -" Rxvt.color1 : #CC0000 -" Rxvt.color9 : #EF2929 -" ! green -" Rxvt.color2 : #4E9A06 -" Rxvt.color10 : #8AE234 -" ! yellow -" Rxvt.color3 : #C4A000 -" Rxvt.color11 : #FCE94F -" ! blue -" Rxvt.color4 : #5971AD -" Rxvt.color12 : #729FCF -" ! magenta -" Rxvt.color5 : #75507B -" Rxvt.color13 : #AD7FA8 -" ! cyan -" Rxvt.color6 : #06989A -" Rxvt.color14 : #34E2E2 -" ! white -" Rxvt.color7 : #D3D7CF -" Rxvt.color15 : #EEEEEE -" -------- -" .Xdefaults 256 (rxvt urxvt setting, vim colorscheme "def256" cterm & gui settings) -" (vim colorscheme "def" cterm matches "def256" if .Xdefaults set thus) -" -------- -" ! black -" Rxvt.color0 : #000000 -" Rxvt.color8 : #808080 -" ! red -" Rxvt.color1 : #DF0000 -" Rxvt.color9 : #FF0000 -" ! green -" Rxvt.color2 : #87DF00 -" Rxvt.color10 : #AFFF00 -" ! yellow -" Rxvt.color3 : #DFAF00 -" Rxvt.color11 : #FFFF00 -" ! blue -" Rxvt.color4 : #5F87DF -" Rxvt.color12 : #87DFFF -" ! magenta -" Rxvt.color5 : #8700DF -" Rxvt.color13 : #87DFFF -" ! cyan -" Rxvt.color6 : #00DFDF -" Rxvt.color14 : #5F5FDF -" ! white -" Rxvt.color7 : #C0C0C0 -" Rxvt.color15 : #FFFFFF -#+END_SRC - -*** frugal-cterm.vim - -#+BEGIN_SRC text :tangle "../misc/editor-syntax-etc/vim/colors/frugal-cterm-sisu.vim" -" Vim color file -" Name: frugal-cterm-sisu -" Maintainer: Ralph Amissah -" Last Change: 2013-02-09 -" URL: -" Note: 8 color cterm, related colorschemes 8 & sparse -:set background=dark -:hi clear -if exists("syntax_on") - syntax reset -endif -:let colors_name = "frugal-cterm-sisu" -" 0 = black, 1 = red, 2 = green, 3 = yellow/orange, 4 = blue, 5 = magenta, 6 = cyan, 7 = white -:hi Normal ctermbg=0 ctermfg=7 -:hi Cursor cterm=reverse -:hi lCursor cterm=reverse -:hi StatusLine cterm=bold,reverse -:hi StatusLineNC cterm=reverse -:hi Search cterm=none ctermbg=2 ctermfg=0 -:hi IncSearch cterm=bold ctermbg=2 ctermfg=7 -:hi SpecialKey ctermfg=4 -:hi Visual cterm=reverse -:hi VisualNOS cterm=bold,underline -:hi MoreMsg ctermfg=2 -:hi ModeMsg cterm=bold -:hi Question ctermfg=2 -:hi Title cterm=bold ctermfg=3 -:hi NonText cterm=bold ctermfg=4 -:hi LineNr cterm=bold ctermbg=0 ctermfg=0* -:hi Directory ctermfg=4 -:hi WildMenu ctermbg=3 ctermfg=0 -:hi VertSplit cterm=reverse -:hi Folded cterm=none ctermbg=0 ctermfg=7 -:hi FoldColumn ctermbg=7 ctermfg=4 -:hi DiffChange cterm=none ctermbg=7 ctermfg=0 -:hi DiffText cterm=none ctermbg=6 ctermfg=0 -:hi DiffAdd cterm=none ctermbg=2 ctermfg=0 -:hi DiffDelete cterm=none ctermbg=7 ctermfg=0 -:hi String cterm=none ctermfg=3 -:hi Comment cterm=none ctermbg=0 ctermfg=7 -:hi Constant ctermfg=1 -:hi Special ctermfg=6 -:hi Identifier ctermfg=6 -:hi Statement ctermfg=6 -:hi Operator ctermfg=1 -:hi PreProc ctermbg=7 ctermfg=1 -:hi Type ctermfg=2 -:hi Delimiter cterm=none ctermfg=1 -:hi Ignore cterm=bold ctermfg=7 -:hi Todo ctermbg=3 ctermfg=0 -:hi Underlined cterm=underline -:hi Include ctermfg=1 -:hi Define ctermfg=3 -:hi Function ctermfg=6 -:hi Structure ctermfg=2 -:hi MatchParen cterm=bold ctermbg=4 ctermfg=7 -:hi CursorLine cterm=bold,underline -:hi CursorColumn cterm=bold -:hi ColorColumn ctermbg=8 -:hi SpellBad cterm=none ctermbg=7 ctermfg=0 -:hi SpellCap cterm=none ctermbg=7 ctermfg=0 -:hi SpellLocal cterm=none ctermbg=7 ctermfg=0 -:hi SpellRare cterm=none ctermbg=7 ctermfg=0 -:hi WarningMsg ctermfg=1 -:hi ErrorMsg cterm=bold ctermbg=1 ctermfg=7 -:hi Error cterm=bold ctermbg=1 ctermfg=7 -#+END_SRC - -** ftplugin sisu.vim - -#+BEGIN_SRC text :tangle "../misc/editor-syntax-etc/vim/ftplugin/sisu.vim" -"%% SiSU Vim ftplugin -" SiSU Maintainer: Ralph Amissah -" SiSU Markup: SiSU (sisu-3.3) 2012-08-18 -" an ftplugin setting defaults for editing sisu markup files -:syntax on -:filetype off -":filetype on -:filetype indent on -:autocmd FileType sisu :set nonumber -:set encoding=utf-8 fileencodings= -:set ff=unix -:set autowrite " Automatically save before commands like :next and :make -:set nocompatible -:set tabstop=2 -:set expandtab -:set shiftwidth=2 -:set autoindent -:set showcmd " Show (partial) command in status line. -:set showmatch " Show matching brackets. -:set ignorecase " Do case insensitive matching -:set smartcase -:set incsearch -:set hlsearch -:set gdefault -:set guioptions=agr " add 'm' for menu -:map :if &guioptions =~# 'm' - \set guioptions-=m - \set guioptions-=T - \else - \set guioptions+=m - \set guioptions-=T - \endif -:set paste -""% statusline -"set statusline= " -"set fillchars=stl:―,stlnc:—,vert:│,fold:۰,diff:· -"" [ buffer number ] -"set statusline +=%#Normal#[ " -"set statusline +=%#Identifier#%n " buffer number -"set statusline +=%#PreProc#%M " modified flag -"set statusline +=%#Normal#] " -"" [ file name (& modified?) ] -"set statusline +=%#Normal#\ [ " -"set statusline +=%#Statement#%<%F%* " full path -""set statusline +=%#Statement#%<%t " full path -"set statusline +=%#PreProc#%M " modified flag -"set statusline +=%#Normal#] " -"" [ column : line number / number of lines in file, percentage of file ] [%v:%l/%L\ %p%%] -"set statusline +=%#Normal#\ [ " -"set statusline +=%#Identifier#%v " column & line -"set statusline +=%#Normal#: " -"set statusline +=%#Identifier#%l " column & line -"set statusline +=%#SpecialKey#/%L\ " total lines -"set statusline +=%#Identifier#%p " percentage of file -"set statusline +=%#SpecialKey#%% " -"set statusline +=%#Normal#] " " -"" [ file format : file type ] -"set statusline +=%#Normal#\ [ " -"set statusline +=%#SpecialKey#%{&fenc} " file format -"set statusline +=%#Normal#: " -"set statusline +=%#SpecialKey#%{&ff} " file format -"set statusline +=%#Normal#: " -"set statusline +=%#SpecialKey#%y " file type -"set statusline +=%#Normal#] " -"" [ character under cursor ] -"set statusline +=%#Normal#\ [ " -"set statusline +=%#String#0x%04B " character under cursor -"set statusline +=%#Normal#]\ " -"" [ syntastic ] -"set statusline +=%#warningmsg# -"set statusline +=%{SyntasticStatuslineFlag()}\ " -""set statusline+=%* -"" Status line background -"set statusline +=%#Folded#\ " -"" misc -"set laststatus=2 " status line always on -"% textwrap -:set whichwrap=<,>,h,l,[,] -:set nolinebreak " only affects display not buffer -:set wrap -:set wrapmargin=0 -"% map -":let mapleader = "," " consider -:map paste :set invpaste -"% wrap/formatting paragraph according to the current 'textwidth' with ^\ (control-\): -:imap gqap -:nmap gqap -:vmap gq -"% save file, go to next file in buffer -:map nf :w :n -"% vimdiff q exits -:if &diff -: cmap q qa -:endif -"% directory files, placed in vertical split window -:map ls :vs :Explore -:map dir :vs :Explore -"% remapping lines make cursor jump a line at a time within wrapped text -:nnoremap j gj -:nnoremap k gk -:vnoremap j gj -:vnoremap k gk -:nnoremap gj -:nnoremap gk -:vnoremap gj -:vnoremap gk -:inoremap gj -:inoremap gk -"% search and replace -:map rd :.,$s///c "search and replace down -:map rg :%s///c "search and replace whole file -:map rr :rubyd gsub!(//,"") -"% pwd t64 working directory set to that of the file you're editing -"changes pwd to directory of file in current buffer -:function! CHANGE_CURR_DIR() -: let _dir = expand("%:p:h") -: exec "cd " . _dir -: unlet _dir -:endfunction -"% Change to the directory the file in your current buffer is in -:if has("autocmd") - autocmd BufEnter * :lcd %:p:h -:endif -"% autocompletefilenames To search for files in the current directory -:set path=,, -"auto-completion for file to edit in current dir, used in normal mode -:map e :e =expand("%:p:h") . "/" -:map pwd :exe 'cd ' . expand ("%:p:h") -"% searchhighlight t93: Toggle search highlight -:function! ToggleHLSearched() -: if &hls -: set nohls -: else -: set hls -: endif -:endfun -:nmap :silent call ToggleHLSearched() -"%% SiSU vim folds -"% foldsearchx FoldSearch (opens result of search all else closed) t77 -:map fs :set foldmethod=expr foldcolumn=2 foldlevel=0 -:map ff :F -:map fe :F zE -"% foldtoggle Fold Toggle mapped to -:fun! ToggleFold() -: if foldlevel('.') == 0 -: normal! l -: else -: if foldclosed('.') < 0 -: foldclose -: else -: foldopen -: endif -: endif -" Clear status line -: echo -:endfun -" Map this function to Space key. -:noremap :call ToggleFold() -"% foldtype Fold? set foldtext -:set foldtext=v:folddashes.substitute(getline(v:foldstart),'\\=','','g',) -:set foldexpr=getline(v:lnum-1)!~@/&&getline(v:lnum)!~@/&&getline(v:lnum+1)!~@/ -"% foldsearch t77: Fold on search result -:function! FoldMake(search) -: set fdm=manual -: normal zE -: normal G$ -: let folded = 0 "flag to set when a fold is found -: let flags = "w" "allow wrapping in the search -: let line1 = 0 "set marker for beginning of fold -: while search(a:search, flags) > 0 -: let line2 = line(".") -: if (line2 -1 > line1) -: "echo line1 . ":" . (line2-1) -: "echo "a fold goes here." -: execute ":" . line1 . "," . (line2-1) . "fold" -: let folded = 1 "at least one fold has been found -: endif -: let line1 = line2 "update marker -: let flags = "W" "turn off wrapping -: endwhile -" create the last fold which goes to the end of the file. -: normal $G -: let line2 = line(".") -: if (line2 > line1 && folded == 1) -: execute ":". line1 . "," . line2 . "fold" -: endif -: normal 1G -:endfunction -"% folds Fold Patterns -:command! -nargs=+ -complete=command FMake call FoldMake() -: if ( &filetype == "ruby" ) -: command! F FMake ^# ==\?\|^\s*\(\(def\|class\|module\)\s\|\(public\|protected\|private\|__END__\)\s*$\)\|\(^\s*\|\s\+\)#%\s -: command! Fa FMake \(^# ==\?\|^\s*\(\(\(def\|class\|module\)\s\)\|\(\(public\|protected\|private\|__END__\)\(\s*$\)\)\)\)\|^[0-9]\~\|\([#%]\|^["]\)\{1,4\}\s*%\|{\({\|!!\) -: command! FD FMake \(^# ==\?\|^\s*\(\(def\|class\|module\)\s\)\)\|^\s*\([#%"0-9]\{0,4\}\~\(%\+\s\|!!\)\|#\s\+=\+\s\+\) -: else -"% folds :F Fold Patterns SiSU Markup :F -: command! F FMake ^\([1-8]\|:\?[A-C]\)\~\|\(^%\|\(^\|\s\+\)[#"]\)%\{1,2\}\(\s\|$\)\|^<<\s*| -: command! Fa FMake ^\([1-8]\|:\?[A-C]\)\~\|\(^%\|\(^\|\s\+\)[#"]\)%\{1,2\}\(\s\|$\)\|^<<\s*|\|^\(Book\|Part\|Chapter\|Section\|Article\|BOOK\|PART\|CHAPTER\|SECTION\|ARTICLE\)\s -: command! F0 FMake ^\(\s*0\~\|@\S\+:[+-]\?\s\+\) -: command! FA FMake ^:\?A\~ -: command! FB FMake ^:\?[AB]\~ -: command! FC FMake ^:\?[A-C]\~ -: command! F1 FMake ^\(:\?[A-C]\|1\)\~ -: command! F2 FMake ^\(:\?[A-C]\|[12]\)\~ -: command! F3 FMake ^\(:\?[A-C]\|[1-3]\)\~ -: command! F4 FMake ^[1-4]\~ -: command! F5 FMake ^[4-5]\~ -: command! F6 FMake ^[4-6]\~ -: command! Fc FMake ^[%]\+\s\+ -: endif -"% folds Fold Patterns misc -":command! Fp FMake ^\s*[A-Za-z0-9#] -:command! Fp FMake ^\s*\S -:command! Fo FMake ^[%\"]\s*[{>] -"% linenumbering, on, relative, off -:map nn :set ={'00':'','01':'r','10':'nor'}[&rnu.&nu]nu -"% cursorline -:map cu :if &cursorcolumn - \set nocursorline nocursorcolumn - \else - \set cursorline cursorcolumn - \endif -:map cu- :set nocursorline nocursorcolumn -:map cu+ :set cursorline cursorcolumn -#+END_SRC - -** templates -*** sst.tpl - -#+BEGIN_SRC text :tangle "../misc/editor-syntax-etc/vim/templates/sst.tpl" -# SiSU 8.0 - -title: - main: "#___#" - sub: "#___#" - language: "#___#" - -creator: - author: "#___#" - -date: - :published: "YYYY-MM-DD" - -rights: - copyright: "#___#" - license: "#___#" - -classify: - topic_register: "#___#" - -make: - breaks: "new=:B; break=1" -# home_button_text: "#___#" -# footer: "#___#" - -#% -- body --- - -:A~ @title @author - -1~ #___# -#+END_SRC - -*** ssm.tpl - -#+BEGIN_SRC text :tangle "../misc/editor-syntax-etc/vim/templates/ssm.tpl" -# SiSU 8.0 master - -title: - main: "#___#" - sub: "#___#" - language: "#___#" - -creator: - author: "#___#" - -date: - :published: "YYYY-MM-DD" - -rights: - copyright: "#___#" - license: "#___#" - -classify: - topic_register: "#___#" - -make: - breaks: "new=:B; break=1" -# home_button_text: "#___#" -# footer: "#___#" - -#% -- body --- - -:A~ @title @author - -1~ #___# -#+END_SRC - -*** ssm.tpl - -#+BEGIN_SRC text :tangle "../misc/editor-syntax-etc/vim/templates/ssi.tpl" -# SiSU 8.0 insert - -title: - main: "#___#" - sub: "#___#" - language: "#___#" - -creator: - author: "#___#" - -date: - :published: "YYYY-MM-DD" - -rights: - copyright: "#___#" - license: "#___#" - -classify: - topic_register: "#___#" - -make: - breaks: "new=:B; break=1" -# home_button_text: "#___#" -# footer: "#___#" - -#% -- body --- - -:A~ @title @author - -1~ #___# -#+END_SRC diff --git a/org/util_spine_markup_conversion_from_sisu.org b/org/util_spine_markup_conversion_from_sisu.org new file mode 100644 index 0000000..8053bcf --- /dev/null +++ b/org/util_spine_markup_conversion_from_sisu.org @@ -0,0 +1,951 @@ +-*- mode: org -*- +#+TITLE: spine (doc_reform) information files +#+DESCRIPTION: documents - structuring, various output representations & search +#+FILETAGS: :spine:info: +#+AUTHOR: Ralph Amissah +#+EMAIL: [[mailto:ralph.amissah@gmail.com][ralph.amissah@gmail.com]] +#+COPYRIGHT: Copyright (C) 2015 - 2020 Ralph Amissah +#+LANGUAGE: en +#+STARTUP: content hideblocks hidestars noindent entitiespretty +#+PROPERTY: header-args :exports code +#+PROPERTY: header-args+ :noweb yes +#+PROPERTY: header-args+ :eval no +#+PROPERTY: header-args+ :results no +#+PROPERTY: header-args+ :cache no +#+PROPERTY: header-args+ :padline no + +* Markup conversion tools + +** README + +#+BEGIN_SRC text :tangle "../misc/util/d/tools/markup_conversion/README" +#+END_SRC + +** endnotes, inline from binary +*** tangle + +#+BEGIN_SRC d :tangle "../misc/util/d/tools/markup_conversion/endnotes_inline_from_binary.d" :tangle-mode (identity #o755) :shebang #!/usr/bin/env rdmd +<> +<> +void main(string[] args) { + <> + foreach(arg; args[1..$]) { + if ( + !(arg.match(regex(r"--\w+"))) + && arg.match(regex(r"\w+?\.ss[itm]")) + ) { + <> + <> + <> + <> + } + } +} +#+END_SRC + +*** head + +#+NAME: inline_notes_head +#+BEGIN_SRC d +/+ + - read in file .sst .ssi .ssm + - loop twice + - first + - check for and skip code blocks + - use unique code marker for endnote markers in text and give an endnote + number ★1, increment + - extract all endnotes in array + - second + - check that the footnote marker number count matches the number of notes + in the array + - if they match either: + - substitute each endnote marker with the array footnote[number-1] + - substitute each endnote marker with footnote + as inlined footnote markup (footnote number not needed) + - if they do not match exit + - check whether changes have been made + - if so write file with inline footnotes in sub-directory converted_output_/ + using the same name as the original file + - else, exit ++/ +#+END_SRC + +*** import + +#+NAME: inline_notes_imports +#+BEGIN_SRC d +import std.stdio; +import std.file; +import std.array : split; +import std.exception; +import core.stdc.errno; +import std.regex; +import std.format; +import std.conv; +#+END_SRC + +*** init + +#+NAME: inline_notes_init +#+BEGIN_SRC d +static comment = ctRegex!(`^%+ `); +static block_tic_code_open = ctRegex!("^`{3} code(?:[.](?P[a-z][0-9a-z#+_]+))?(?:[(](?P[ a-zA-Z0-9;:,]*)[)])?"); +static block_tic_close = ctRegex!("^(`{3})$","m"); +static block_curly_code_open = ctRegex!(`^(?:code(?:[.](?P[a-z][0-9a-z_]+))?(?:[(](?P[ a-zA-Z0-9;:,]*)[)])?[{][ ]*$)`); +static block_curly_code_close = ctRegex!(`^([}]code)`); +auto rgx_endnote_ref = ctRegex!(`([~]\^)(?P[)\]]? |$)`, "gm"); +auto rgx_endnote = ctRegex!(`^\^~\s+(.+|\n)`, "gm"); +#+END_SRC + +*** pre-loops + +#+NAME: inline_notes_pre_loops +#+BEGIN_SRC d +writeln(arg); +string filename = arg; +try { + string[] contents, endnotes, endnote_refs; + string text = filename.readText; + string[] paragraphs = text.split("\n\n"); + int endnote_ref_count = 0; + int[string] type = [ + "curly_code" : 0, + "tic_code" : 0, + ]; +#+END_SRC + +*** loop doc body + +#+NAME: inline_notes_loop_doc_body +#+BEGIN_SRC d +foreach (paragraph; paragraphs) { /+ loop to gather binary endnotes +/ + if ( !( type["curly_code"] == 1 || type["tic_code"] == 1) + && paragraph.match(rgx_endnote) + ) { + endnotes ~= replaceAll!(m => m[1]) + (paragraph, rgx_endnote); + } else { + if ( type["curly_code"] == 1 + && paragraph.matchFirst(block_curly_code_close) + ) { + type["curly_code"] = 0; + } else if (type["tic_code"] == 1 + && paragraph.matchFirst(block_tic_close) + ) { + type["tic_code"] = 0; + } else if ( type["curly_code"] == 1 || type["tic_code"] == 1) { + // skip, prevent search for endnotes + } else if (paragraph.matchFirst(block_curly_code_open)) { + type["curly_code"] = 1; + } else if (paragraph.matchFirst(block_tic_code_open)) { + type["tic_code"] = 1; + } else if (auto m = paragraph.matchAll(rgx_endnote_ref)) { + foreach (n; m) { + endnote_ref_count++; // endnote_refs ~= (n.captures[1]); + } + } + contents ~= paragraph; + } +} +#+END_SRC + +*** (loop to) adjustment & output + +#+NAME: inline_notes_loop_adjust_and_output +#+BEGIN_SRC d +if (endnotes.length == endnote_ref_count) { + import std.outbuffer; + writeln("endnote ref count: ", endnote_ref_count); + writeln("number of binary endnotes: ", endnotes.length); + int endnote_count = -1; + auto buffer = new OutBuffer(); + foreach (content; contents) { /+ loop to inline endnotes +/ + content = replaceAll!(m => "~{ " ~ endnotes[++endnote_count] ~ " }~" ~ m["tail"] ) + (content, rgx_endnote_ref); + buffer.write(content ~ "\n\n"); + } + if (buffer) { + try { + string dir_out = "converted_output_"; + string path_and_file_out = dir_out ~ "/" ~ filename; + dir_out.mkdirRecurse; + auto f = File(path_and_file_out, "w"); + f.write(buffer); + writeln("wrote: ", path_and_file_out); + } catch (FileException ex) { + writeln("did not write file"); + // Handle errors + } + } +} else { + writeln("ERROR binary endnote mismatch, check markup,\nmisatch in the number of endnotes & endnote references!"); + writeln(" number of endnotes: ", endnotes.length); + writeln(" number of endnote refs: ", endnote_ref_count); // endnote_refs.length, +} +// assert(endnotes.length == endnote_ref_count); +#+END_SRC + +*** exceptions + +#+NAME: inline_notes_exceptions +#+BEGIN_SRC d +} catch (ErrnoException ex) { + switch(ex.errno) { + case EPERM: + case EACCES: // Permission denied + break; + case ENOENT: // File does not exist + break; + default: // Handle other errors + break; + } +} +#+END_SRC + +** conversion from sisu (sisu bespoke headers) any binary to inline notes TODO +*** tangle + +#+BEGIN_SRC d :tangle "../misc/util/d/tools/markup_conversion/markup_conversion_from_sisu_ruby_to_sisu_spine.d" :tangle-mode (identity #o755) :shebang #!/usr/bin/env rdmd +<> +<> +void main(string[] args) { + <> + <> + <> + foreach(arg; args[1..$]) { + if ( + !(arg.match(regex(r"--\w+"))) + && arg.match(regex(r"\w+?\.ss[itm]")) + ) { + <> + <> + <> + <> + <> + } + } +} +#+END_SRC + +*** head + +#+NAME: from_sisu_rb_head +#+BEGIN_SRC d +/+ + - read in file .sst .ssi .ssm + - loop twice + - first + - check for and skip code blocks + - use unique code marker for endnote markers in text and give an endnote + number ★1, increment + - extract all endnotes in array + - second + - check that the footnote marker number count matches the number of notes + in the array + - if they match either: + - substitute each endnote marker with the array footnote[number-1] + - substitute each endnote marker with footnote + as inlined footnote markup (footnote number not needed) + - if they do not match exit + - check whether changes have been made + - if so write file with inline footnotes in sub-directory converted_output_/ + using the same name as the original file + - else, exit ++/ +#+END_SRC + +*** import + +#+NAME: from_sisu_rb_imports +#+BEGIN_SRC d +import std.stdio; +import std.file; +import std.array : split, join; +import std.exception; +// import std.range; +import core.stdc.errno; +import std.regex; +import std.format; +import std.conv; +#+END_SRC + +*** init + +#+NAME: from_sisu_rb_init +#+BEGIN_SRC d +static heading_a = ctRegex!(`^:?[A][~] `, "m"); +static comment = ctRegex!(`^%+ `); +static block_tic_code_open = ctRegex!("^`{3} code(?:[.](?P[a-z][0-9a-z#+_]+))?(?:[(](?P[ a-zA-Z0-9;:,]*)[)])?"); +static block_tic_close = ctRegex!("^(`{3})$","m"); +static block_curly_code_open = ctRegex!(`^(?:code(?:[.](?P[a-z][0-9a-z_]+))?(?:[(](?P[ a-zA-Z0-9;:,]*)[)])?[{][ ]*$)`); +static block_curly_code_close = ctRegex!(`^([}]code)`); +auto rgx_endnote_ref = ctRegex!(`([~]\^)(?P[)\]]? |$)`, "gm"); +auto rgx_endnote = ctRegex!(`^\^~\s+(.+|\n)`, "gm"); +char[][] header0Content1(in string src_text) { // cast(char[]) + /+ split string on _first_ match of "^:?A~\s" into [header, content] array/tuple +/ + char[][] header_and_content; + auto m = (cast(char[]) src_text).matchFirst(heading_a); + header_and_content ~= m.pre; + header_and_content ~= m.hit ~ m.post; + assert(header_and_content.length == 2, + "document markup is broken, header body split == " + ~ header_and_content.length.to!string + ~ "; (header / body array split should == 2 (split is on level A~))" + ); + return header_and_content; +} +#+END_SRC + +*** body format +**** format body string + +#+NAME: from_sisu_rb_body_format +#+BEGIN_SRC d +string format_body_string(string s) { + string o; + o = s + .replaceAll(regex("^<(?:/[ ]*)?br>[ ]*"), " \\\\ ") + .replaceAll(regex("[ ]*<(?:/[ ]*)?br>$"), " \\\\") + .replaceAll(regex("[ ]*<(?:/[ ]*)?br>[ ]*"), " \\\\ "); + return o; +} +#+END_SRC + +*** header format +**** format header string + +#+NAME: from_sisu_rb_header_format +#+BEGIN_SRC d +string format_header_string(string s) { + string o; + o = s + .replaceAll(regex("\""), "\\\"") + .replaceAll(regex("[ ]*<(?:/[ ]*)?br>$"), " \\\\") + .replaceAll(regex("[ ]*<(?:/[ ]*)?br>[ ]*"), " \\\\ "); + return o; +} +#+END_SRC + +**** format main header + +#+NAME: from_sisu_rb_header_format +#+BEGIN_SRC d +string format_main_header(string hm, string hs = "", string c = "") { + string o; + if (c.length == 0) { + o ~= hm ~ ":\n"; + } else { + o ~= hm ~ ":\n" + ~ " " ~ hs ~ ": " + ~ "\"" ~ format_header_string(c) ~ "\"\n"; + } + return o; +} +#+END_SRC + +**** format sub header + +#+NAME: from_sisu_rb_header_format +#+BEGIN_SRC d +string format_sub_header(string hs, string c) { + string o; + o ~= " " ~ hs ~ ": " + ~ "\"" ~ format_header_string(c) ~ "\"\n"; + return o; +} + #+END_SRC + +*** pre-loops + +#+NAME: from_sisu_rb_pre_loops +#+BEGIN_SRC d +writeln(arg); +string filename = arg; +try { + string[] munged_header, munged_contents, munged_endnotes, endnote_refs; + string text = filename.readText; + char[][] hc = header0Content1(text); + char[] src_header = hc[0]; + string[] headers = src_header.to!string.split("\n\n"); + char[] src_txt = hc[1]; + string[] paragraphs = src_txt.to!string.split("\n\n"); + int endnote_ref_count = 0; + int[string] type = [ + "curly_code" : 0, + "tic_code" : 0, + ]; + string _tmp_header; +#+END_SRC + +*** loop doc header + +#+NAME: from_sisu_rb_loop_doc_header +#+BEGIN_SRC d +headers[0] = headers[0].replaceFirst(regex(r"^%\s+SiSU.+", "i"), "# SiSU 8.0 spine (auto-conversion)"); +foreach (h_; headers) { + _tmp_header = ""; + if (auto m = h_.match(regex(r"^%\s*", "m"))) { + h_ = h_.replaceAll(regex(r"^%\s*", "m"), "# ") ~ "\n"; + } + if (h_.match(regex(r"^@title:|@subtitle"))) { + if (auto m = h_.match(regex(r"^@(?Ptitle):(?:[ ]+(?P.+)|\n)"))) { + _tmp_header ~= format_main_header(m.captures["h"], "main", m.captures["c"]); + } + if (auto m = h_.match(regex(r"^@(?Psubtitle):(?:[ ]+(?P.+)|$)"))) { + if (m.captures["c"].length == 0) { + } else { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + } + if (auto m = h_.match(regex(r"^\s+:(?Pmain):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:sub(?:title)?:(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header("subtitle", m.captures["c"]); + } + } else if (h_.match(regex(r"^@creator:|@author:"))) { + if (auto m = h_.match(regex(r"^(?:@creator:|@author:)(?:[ ]+(?P.+)|\n)"))) { + _tmp_header ~= format_main_header("creator", "author", m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pauthor):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + } else if (h_.match(regex(r"^@rights:"))) { + if (auto m = h_.match(regex(r"^@(?Prights):(?:[ ]+(?P.+)|\n)"))) { + _tmp_header ~= format_main_header(m.captures["h"], "copyright", m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pcopyright):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:licen[cs]e:(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header("license", m.captures["c"]); + } + } else if (h_.match(regex(r"^@date:|@date\."))) { + if (auto m = h_.match(regex(r"^@(?Pdate):(?:[ ]+(?P.+)|\n)"))) { + _tmp_header ~= format_main_header(m.captures["h"], "published", m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Ppublished):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pavailable):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pmodified):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pcreated):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pissued):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pvalid):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^@date\.(?Pavailable):[ ]+(?P.+)$"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^@date\.(?Pmodified):[ ]+(?P.+)$"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^@date\.(?Pcreated):[ ]+(?P.+)$"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^@date\.(?Pissued):[ ]+(?P.+)$"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^@date\.(?Pvalid):[ ]+(?P.+)$"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + } else if (h_.match(regex(r"^@classify:"))) { + if (auto m = h_.match(regex(r"^@classify:"))) { + _tmp_header ~= "classify:\n"; + } + if (auto m = h_.match(regex(r"^\s+:(?Ptopic_register):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:type:(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= "# type: " ~ "\"" ~ m.captures["c"] ~ "\"\n"; + } + } else if (h_.match(regex(r"^(?:@identifier:|@identify:)"))) { + if (auto m = h_.match(regex(r"^(?:@identifier:|@idenfify)"))) { + _tmp_header ~= "identify:\n"; + } + if (auto m = h_.match(regex(r"^\s+:(?Poclc):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pisbn):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pdewey):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + } else if (h_.match(regex(r"^@publisher:"))) { + if (auto m = h_.match(regex(r"^@publisher:[ ]+(?P.+)$"))) { + _tmp_header ~= "publisher: " ~ "\"" ~ m.captures["c"] ~ "\"\n"; + } + } else if (h_.match(regex(r"^@make:"))) { + // writeln(h_); + if (auto m = h_.match(regex(r"^@make:"))) { + _tmp_header ~= "make:\n"; + } + if (auto m = h_.match(regex(r"^\s+:(?Pbreaks):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pnum_top):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pheadings):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pitalics):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pbold):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pemphasis):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Ptexpdf_font):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Phome_button_text):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Phome_button_image):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pcover_image):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + if (auto m = h_.match(regex(r"^\s+:(?Pfooter):(?:[ ]+(?P.+)|$)", "m"))) { + _tmp_header ~= format_sub_header(m.captures["h"], m.captures["c"]); + } + // writeln(_tmp_header); + } else if (h_.match(regex(r"^@\w+:"))) { + _tmp_header ~= "# " ~ h_.split("\n").join("\n# ") ~ "\n"; + } else if (h_.match(regex(r"^\s+:\w+:", "m"))) { + if (auto m = h_.match(regex(r"^(?P\s+:\w+:.*)"))) { + _tmp_header ~= "# " ~ m.captures["g"] ~ "\n"; + } + } + if (h_.match(regex(r"^#", "m"))) { + if (auto m = h_.match(regex(r"^(?P#.*)", "m"))) { + _tmp_header ~= m.captures["g"] ~ "\n"; + } + } + if (_tmp_header.length > 0) { + munged_header ~= _tmp_header.split("\n\n"); + } else if (h_.length > 0) { + writeln("munging required: ", h_); + h_ = h_.replaceAll((regex(r"\n\n\n+", "m")), "\n\n"); + munged_header ~= h_; + } +} +// writeln(munged_header.join("\n")); +#+END_SRC + +*** loop doc body (identify & ignore code blocks) + +#+NAME: from_sisu_rb_loop_doc_body +#+BEGIN_SRC d +foreach (paragraph; paragraphs) { /+ loop to gather binary endnotes +/ + if ( !( type["curly_code"] == 1 || type["tic_code"] == 1) + && paragraph.match(rgx_endnote) + ) { + munged_endnotes ~= replaceAll!(m => m[1]) + (paragraph, rgx_endnote); + } else { + if ( type["curly_code"] == 1 || type["tic_code"] == 1 + || paragraph.matchFirst(block_curly_code_open) + || paragraph.matchFirst(block_tic_code_open) + ) { /+ code blocks identified, no munging +/ + if ( type["curly_code"] == 1 + && paragraph.matchFirst(block_curly_code_close) + ) { + type["curly_code"] = 0; + } else if (type["tic_code"] == 1 + && paragraph.matchFirst(block_tic_close) + ) { + type["tic_code"] = 0; + } else if (paragraph.matchFirst(block_curly_code_open)) { + type["curly_code"] = 1; + } else if (paragraph.matchFirst(block_tic_code_open)) { + type["tic_code"] = 1; + } + munged_contents ~= paragraph; + } else { /+ regular content, not a code block +/ + if (auto m = paragraph.matchAll(rgx_endnote_ref)) { + foreach (n; m) { + endnote_ref_count++; // endnote_refs ~= (n.captures[1]); + } + } + paragraph = format_body_string(paragraph); + // paragraph = replaceAll!(m => " \\\\ " ) + // (paragraph, regex(r"\s*<(?:/\s*|:)?br>\s*")); // (paragraph, regex(r"(
)")); + munged_contents ~= paragraph; + } + } +} +#+END_SRC + +*** (loop to) adjustment & output + +#+NAME: from_sisu_rb_loop_adjust_and_output +#+BEGIN_SRC d +{ + import std.outbuffer; + auto buffer = new OutBuffer(); + foreach (header; munged_header) { /+ loop to inline endnotes +/ + buffer.write(header ~ "\n"); + } + if (munged_endnotes.length == endnote_ref_count) { + int endnote_count = -1; + foreach (content; munged_contents) { /+ loop to inline endnotes +/ + content = replaceAll!(m => "~{ " ~ munged_endnotes[++endnote_count] ~ " }~" ~ m["tail"] ) + (content, rgx_endnote_ref); // endnote_ref cannot occur in a code block or else fail + buffer.write(content ~ "\n\n"); + } + if (buffer) { + try { + string dir_out = "converted_output_"; + string path_and_file_out = dir_out ~ "/" ~ filename; + dir_out.mkdirRecurse; + auto f = File(path_and_file_out, "w"); + f.write(buffer); + // writeln("wrote: ", path_and_file_out); + } catch (FileException ex) { + writeln("did not write file"); + // Handle errors + } + } + } else { + foreach (content; munged_contents) { /+ loop to inline endnotes +/ + buffer.write(content ~ "\n\n"); + } + } +} +#+END_SRC + +*** exceptions + +#+NAME: from_sisu_rb_exceptions +#+BEGIN_SRC d +} catch (ErrnoException ex) { + switch(ex.errno) { + case EPERM: + case EACCES: // Permission denied + break; + case ENOENT: // File does not exist + break; + default: // Handle other errors + break; + } +} +#+END_SRC + +** conversion from sisu and multiple headers (sisu bespoke, sdlang, toml) incomplete +*** tangle + +#+BEGIN_SRC d :tangle "../misc/util/d/tools/markup_conversion/markup_changes_header_and_content.d" :tangle-mode (identity #o755) :shebang #!/usr/bin/env rdmd +<> +<> +void main(string[] args) { + <> + foreach(arg; args[1..$]) { + if ( + !(arg.match(regex(r"--\w+"))) + && arg.match(regex(r"\w+?\.ss[itm]")) + ) { + <> + <> + <> + <> + <> + } + } +} +#+END_SRC + +*** head + +#+NAME: from_previous_markups_head +#+BEGIN_SRC d +/+ + - read in file .sst .ssi .ssm + - loop twice + - first + - check for and skip code blocks + - use unique code marker for endnote markers in text and give an endnote + number ★1, increment + - extract all endnotes in array + - second + - check that the footnote marker number count matches the number of notes + in the array + - if they match either: + - substitute each endnote marker with the array footnote[number-1] + - substitute each endnote marker with footnote + as inlined footnote markup (footnote number not needed) + - if they do not match exit + - check whether changes have been made + - if so write file with inline footnotes in sub-directory converted_output_/ + using the same name as the original file + - else, exit ++/ +#+END_SRC + +*** imports + +#+NAME: from_previous_markups_imports +#+BEGIN_SRC d +import std.stdio; +import std.file; +import std.array : split; +import std.exception; +// import std.range; +import core.stdc.errno; +import std.regex; +import std.format; +import std.conv; +#+END_SRC + +*** init + +#+NAME: from_previous_markups_init +#+BEGIN_SRC d +static heading_a = ctRegex!(`^:?[A][~] `, "m"); +static comment = ctRegex!(`^%+ `); +static block_tic_code_open = ctRegex!("^`{3} code(?:[.](?P[a-z][0-9a-z#+_]+))?(?:[(](?P[ a-zA-Z0-9;:,]*)[)])?"); +static block_tic_close = ctRegex!("^(`{3})$","m"); +static block_curly_code_open = ctRegex!(`^(?:code(?:[.](?P[a-z][0-9a-z_]+))?(?:[(](?P[ a-zA-Z0-9;:,]*)[)])?[{][ ]*$)`); +static block_curly_code_close = ctRegex!(`^([}]code)`); +auto rgx_endnote_ref = ctRegex!(`([~]\^)(?P[)\]]? |$)`, "gm"); +auto rgx_endnote = ctRegex!(`^\^~\s+(.+|\n)`, "gm"); +char[][] header0Content1(in string src_text) { // cast(char[]) + /+ split string on _first_ match of "^:?A~\s" into [header, content] array/tuple +/ + char[][] header_and_content; + auto m = (cast(char[]) src_text).matchFirst(heading_a); + header_and_content ~= m.pre; + header_and_content ~= m.hit ~ m.post; + assert(header_and_content.length == 2, + "document markup is broken, header body split == " + ~ header_and_content.length.to!string + ~ "; (header / body array split should == 2 (split is on level A~))" + ); + return header_and_content; +} +#+END_SRC + +*** pre-loops + +#+NAME: from_previous_markups_pre_loops +#+BEGIN_SRC d +writeln(arg); +string filename = arg; +try { + string[] munged_header, munged_contents, munged_endnotes, endnote_refs; + string text = filename.readText; + char[][] hc = header0Content1(text); + char[] src_header = hc[0]; + string[] headers = src_header.to!string.split("\n\n"); + char[] src_txt = hc[1]; + string[] paragraphs = src_txt.to!string.split("\n\n"); + int endnote_ref_count = 0; + int[string] type = [ + "curly_code" : 0, + "tic_code" : 0, + ]; + string _tmp_header; +#+END_SRC + +*** loop doc header + +#+NAME: from_previous_markups_loop_doc_header +#+BEGIN_SRC d +foreach (h_; headers) { /+ loop to inline endnotes +/ + _tmp_header = ""; + if (h_.match(regex(r"^[@\[]?title[:\]]?"))) { // title + if (auto m = h_.match(regex(r"^@title:(?:\s+(?P.+)|$)"))) { // sisu bespoke markup + if (m.captures["c"].length == 0) { + _tmp_header ~= "title:"; + } else { + _tmp_header ~= "title:\n main: " ~ "\"" ~ m.captures["c"] ~ "\""; + } + } else if (auto m = h_.match(regex(r"^title\s*=\s*(?P.+)"))) { // toml? + if (m.captures["c"].length == 0) { + _tmp_header ~= "title:"; + } else { + _tmp_header ~= "title:\n main: " ~ "\"" ~ m.captures["c"] ~ "\""; + } + } else if (auto m = h_.match(regex(r"^\[title\]"))) { // toml markup + _tmp_header ~= "title:"; + } else if (auto m = h_.match(regex(r"^title(?:\s+(?P.+)|\s+\\$)"))) { // sdlang markup + if (m.captures["c"].length == 0) { + _tmp_header ~= "title:"; + } else { + _tmp_header ~= "title:\n main: " ~ "\"" ~ m.captures["c"] ~ "\""; + } + } + if (h_.match(regex(r"^\s*[:]?(?:main)[:= ]?", "m"))) { + if (auto m = h_.match(regex(r"^\s+(?P:main):(?:\s+(?P.+)|$)", "m"))) { // sisu bespoke markup + _tmp_header ~= " main: " ~ "\"" ~ m.captures["c"] ~ "\""; + } else if (auto m = h_.match(regex(r"^\s*(?Pmain)\s*=\s*(?P.+)", "m"))) { // toml? + _tmp_header ~= " main: " ~ m.captures["c"]; + } else if (auto m = h_.match(regex(r"^\s+(?Pmain)(?:\s*\s*(?P.+)|$)", "m"))) { // toml markup + _tmp_header ~= " main: " ~ "\"" ~ m.captures["c"] ~ "\""; + } else if (auto m = h_.match(regex(r"^\s+(?Pmain)(?:\s+(?P.+)|\s+\\$)", "m"))) { // sdlang markup + _tmp_header ~= " main: " ~ "\"" ~ m.captures["c"] ~ "\""; + } + } + if (h_.match(regex(r"^\s*[:]?(?:sub(title)?)[:= ]?", "m"))) { + if (auto m = h_.match(regex(r"^\s+:sub(?:title)?:(?:\s+(?P.+)|$)", "m"))) { // sisu bespoke markup + _tmp_header ~= " subtitle: " ~ "\"" ~ m.captures["c"] ~ "\""; + } else if (auto m = h_.match(regex(r"^\s*sub(?:title)?\s*=\s*(?P.+)$", "m"))) { // toml? + _tmp_header ~= " subtitle: " ~ m.captures["c"]; + } else if (auto m = h_.match(regex(r"^\s+(?:title)?(?:\s*\s*(?P.+)|$)", "m"))) { // toml markup + _tmp_header ~= " subtitle: " ~ "\"" ~ m.captures["c"] ~ "\""; + } else if (auto m = h_.match(regex(r"^\s+(?:title)?(?:\s+(?P.+)|\s+\\$)", "m"))) { // sdlang markup + _tmp_header ~= " subtitle: " ~ "\"" ~ m.captures["c"] ~ "\""; + } + } + } + if (h_.match(regex(r"^[@\[]?rights[:\]]?"))) { // rights + if (auto m = h_.match(regex(r"^@rights:[ ]+(?P.+)$"))) { // sisu bespoke markup + _tmp_header ~= "rights: \n copyright: \"" ~ m.captures["c"] ~ "\""; + } else if (auto m = h_.match(regex(r"^@rights:"))) { // sisu bespoke markup + _tmp_header ~= "rights:"; + } else if (auto m = h_.match(regex(r"^\[rights\]", "m"))) { // toml markup + _tmp_header ~= "rights:"; + } else if (auto m = h_.match(regex(r"^rights:"))) { // sdlang markup + _tmp_header ~= "rights:"; + } + if (h_.match(regex(r"^\s*[:]?copyright[:= ]?", "m"))) { + if (auto m = h_.match(regex(r"^\s+:copyright:(?:\s+(?P.+)|$)", "m"))) { // sisu bespoke markup + _tmp_header ~= " copyright: " ~ "\"" ~ m.captures["c"] ~ "\""; + } else if (auto m = h_.match(regex(r"^\s*copyright\s*=\s*(?P.+)", "m"))) { // toml? + _tmp_header ~= " copyright: " ~ m.captures["c"]; + } else if (auto m = h_.match(regex(r"^\s+copyright(?:\s*\s*(?P.+)|$)", "m"))) { // toml markup + _tmp_header ~= " copyright: " ~ "\"" ~ m.captures["c"] ~ "\""; + } else if (auto m = h_.match(regex(r"^\s+copyright(?:\s+(?P.+)|\s+\\$)", "m"))) { // sdlang markup + _tmp_header ~= " copyright: " ~ "\"" ~ m.captures["c"] ~ "\""; + } + } + if (h_.match(regex(r"^\s*[:]?licen[cs]e[:= ]?", "m"))) { + if (auto m = h_.match(regex(r"^\s+:licen[cs]e:(?:\s+(?P.+)|$)", "m"))) { // sisu bespoke markup + _tmp_header ~= " license: " ~ "\"" ~ m.captures["c"] ~ "\""; + } else if (auto m = h_.match(regex(r"^\s*licen[cs]e\s*=\s*(?P.+)$", "m"))) { // toml? + _tmp_header ~= " license: " ~ m.captures["c"]; + } else if (auto m = h_.match(regex(r"^\s+licen[cs]e(?:\s*\s*(?P.+)|$)", "m"))) { // toml markup + _tmp_header ~= " license: " ~ "\"" ~ m.captures["c"] ~ "\""; + } else if (auto m = h_.match(regex(r"^\s+licen[cs]e(?:\s+(?P.+)|\s+\\$)", "m"))) { // sdlang markup + _tmp_header ~= " license: " ~ "\"" ~ m.captures["c"] ~ "\""; + } + } + } + if (_tmp_header.length > 0) { + munged_header ~= _tmp_header; + } else { + munged_header ~= h_; + } +} +writeln(munged_header); +#+END_SRC + +*** loop doc body + +#+NAME: from_previous_markups_loop_doc_body +#+BEGIN_SRC d +foreach (paragraph; paragraphs) { /+ loop to gather binary endnotes +/ + if ( !( type["curly_code"] == 1 || type["tic_code"] == 1) + && paragraph.match(rgx_endnote) + ) { + munged_endnotes ~= replaceAll!(m => m[1]) + (paragraph, rgx_endnote); + } else { + if ( type["curly_code"] == 1 || type["tic_code"] == 1 + || paragraph.matchFirst(block_curly_code_open) + || paragraph.matchFirst(block_tic_code_open) + ) { /+ code blocks identified, no munging +/ + if ( type["curly_code"] == 1 + && paragraph.matchFirst(block_curly_code_close) + ) { + type["curly_code"] = 0; + } else if (type["tic_code"] == 1 + && paragraph.matchFirst(block_tic_close) + ) { + type["tic_code"] = 0; + } else if (paragraph.matchFirst(block_curly_code_open)) { + type["curly_code"] = 1; + } else if (paragraph.matchFirst(block_tic_code_open)) { + type["tic_code"] = 1; + } + munged_contents ~= paragraph; + } else { /+ regular content, not a code block +/ + if (auto m = paragraph.matchAll(rgx_endnote_ref)) { + foreach (n; m) { + endnote_ref_count++; // endnote_refs ~= (n.captures[1]); + } + } + paragraph = replaceAll!(m => " \\\\ " ) + (paragraph, regex(r"\s*<(?:/\s*|:)?br>\s*")); // (paragraph, regex(r"(
)")); + munged_contents ~= paragraph; + } + } +} +#+END_SRC + +*** (loop to) adjust & output + +#+NAME: from_previous_markups_loop_adjust_and_output +#+BEGIN_SRC d +{ + import std.outbuffer; + auto buffer = new OutBuffer(); + foreach (header; munged_header) { /+ loop to inline endnotes +/ + buffer.write(header ~ "\n\n"); + } + if (munged_endnotes.length == endnote_ref_count) { + int endnote_count = -1; + foreach (content; munged_contents) { /+ loop to inline endnotes +/ + content = replaceAll!(m => "~{ " ~ munged_endnotes[++endnote_count] ~ " }~" ~ m["tail"] ) + (content, rgx_endnote_ref); // endnote_ref cannot occur in a code block or else fail + buffer.write(content ~ "\n\n"); + } + if (buffer) { + try { + string dir_out = "converted_output_"; + string path_and_file_out = dir_out ~ "/" ~ filename; + dir_out.mkdirRecurse; + auto f = File(path_and_file_out, "w"); + f.write(buffer); + // writeln("wrote: ", path_and_file_out); + } catch (FileException ex) { + writeln("did not write file"); + // Handle errors + } + } + } else { + foreach (content; munged_contents) { /+ loop to inline endnotes +/ + buffer.write(content ~ "\n\n"); + } + } +} +#+END_SRC + +*** exceptions + +#+NAME: from_previous_markups_exceptions +#+BEGIN_SRC d +} catch (ErrnoException ex) { + switch(ex.errno) { + case EPERM: + case EACCES: // Permission denied + break; + case ENOENT: // File does not exist + break; + default: // Handle other errors + break; + } +} +#+END_SRC diff --git a/org/util_spine_syntax_highlighting_emacs.org b/org/util_spine_syntax_highlighting_emacs.org new file mode 100644 index 0000000..0007e48 --- /dev/null +++ b/org/util_spine_syntax_highlighting_emacs.org @@ -0,0 +1,539 @@ +-*- mode: org -*- +#+TITLE: spine (doc_reform) information files +#+DESCRIPTION: documents - structuring, various output representations & search +#+FILETAGS: :spine:info: +#+AUTHOR: Ralph Amissah +#+EMAIL: [[mailto:ralph.amissah@gmail.com][ralph.amissah@gmail.com]] +#+COPYRIGHT: Copyright (C) 2015 - 2020 Ralph Amissah +#+LANGUAGE: en +#+STARTUP: content hideblocks hidestars noindent entitiespretty +#+PROPERTY: header-args :exports code +#+PROPERTY: header-args+ :noweb yes +#+PROPERTY: header-args+ :eval no +#+PROPERTY: header-args+ :results no +#+PROPERTY: header-args+ :cache no +#+PROPERTY: header-args+ :padline no + +* Emacs Syntax highlighting + +** README + +#+BEGIN_SRC elisp :tangle "../misc/editor-syntax-etc/emacs/README" +; put this into your .emacs file, then use the mode file: + +(load-file "~/emacs/el/sisu-spine-mode.el") +(add-to-list 'auto-mode-alist '("\\.sst$" . sisu-spine-mode)) +#+END_SRC + +** autoload sisuspine-mode-autoloads.el + +#+BEGIN_SRC elisp :tangle "../misc/editor-syntax-etc/emacs/sisu-spine-mode-autoloads.el" +(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) +(autoload 'sisu-spine-mode "sisu-spine-mode" "\ +Major mode for editing SiSU (spine) markup files. +SiSU (http://www.sisudoc.org/) document structuring, publishing +and search. + +\(fn)" t nil) +(add-to-list 'auto-mode-alist '("\\.sst\\'" . sisu-spine-mode)) +(add-to-list 'auto-mode-alist '("\\.ssm\\'" . sisu-spine-mode)) +(add-to-list 'auto-mode-alist '("\\.ssi\\'" . sisu-spine-mode)) +#+END_SRC + +** mode sisu-spine-mode.el + +#+BEGIN_SRC elisp :tangle "../misc/editor-syntax-etc/emacs/sisu-spine-mode.el" +;;; sisu-spine-mode.el --- Major mode for SiSU (spine parser) markup text + +;; Copyright (C) 2011, 2020 Free Software Foundation, Inc. + +;; Author: Ralph Amissah & Ambrose Kofi Laing +;; Maintainer: Ralph Amissah +;; Keywords: text, syntax, processes, tools +;; Version: 8.0.0 +;; URL: http://www.sisudoc.org/ +;; originally looked at (based on) doc-mode, with kind permission of the author +;; Author: SUN, Tong , (c)2001-6, all right reserved +;; Version: $Date: 2006/01/19 03:13:41 $ $Revision: 1.14 $ +;; Home URL: http://xpt.sourceforge.net/ +;; with contributions from Kevin Ryde and Stefan Monnier + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;; Viva Software Libre! +;; Support the free software movement! +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;; Commentary: + +;; SiSU (http://www.sisudoc.org/) is a document structuring and +;; publishing framework. This package provides an Emacs major mode +;; for SiSU markup, as used by the spine parser (in D) which has a different +;; header (based on yaml) from the original sisu parser (in Ruby) which has +;; bespoke headers. + +;; When this package is installed, files ending in ".sst" are automatically +;; associated with sisu-spine-mode. If a file doesn't have a +;; .sst extension, add a first line: +;; # -*- sisuSpine -*- + +;; The documentation for the "Structure Of The Hierarchy Text" can be +;; found in the sisustring for the sisu-spine-mode function. + +;;; Code: + +;; Variables: + +(defgroup sisu-faces nil + "AsciiSisu highlighting" + :group 'sisus) + +;; == Colors +; color n is more prominent than color n+1 + +(defface sisu-title-1-face + `((((class color) + (background dark)) + (:foreground "brown3" :bold t :height 1.2 :inherit variable-pitch)) + (((class color) + (background light)) + (:foreground "brown3" :bold t :height 1.2 :inherit variable-pitch)) + (t (:weight bold :inherit variable-pitch))) + "Face for AsciiSisu titles at level 1." + :group 'sisu-faces) + +(defface sisu-title-2-face + `((((class color) + (background dark)) + (:foreground "yellow4" :bold t :height 1.1 :inherit variable-pitch)) + (((class color) + (background light)) + (:foreground "yellow4" :bold t :height 1.1 :inherit variable-pitch)) + (t (:weight bold :inherit variable-pitch))) + "Face for AsciiSisu titles at level 2." + :group 'sisu-faces) + +(defface sisu-title-3-face + `((((class color) + (background dark)) + (:foreground "sienna3" :bold t)) + (((class color) + (background light)) + (:foreground "sienna3" :bold t)) + (t (:weight bold))) + "Face for AsciiSisu titles at level 3." + :group 'sisu-faces) + +(defface sisu-title-4-face + `((((class color) + (background dark)) + (:foreground "burlywood3")) + (((class color) + (background light)) + (:foreground "burlywood3")) + (t ())) + "Face for AsciiSisu titles at level 4." + :group 'sisu-faces) + +(defface info-node + '((((class color) (background light)) (:foreground "brown" :bold t :italic t)) + (((class color) (background dark)) (:foreground "white" :bold t :italic t)) + (t (:bold t :italic t))) + "Face for Info node names." + :group 'sisu-faces) + +(defvar sisu-title-1 'sisu-title-1-face) +(defvar sisu-title-2 'sisu-title-2-face) +(defvar sisu-title-3 'sisu-title-3-face) +(defvar sisu-title-4 'sisu-title-4-face) + +(defvar sisu-general-font-lock-red1 font-lock-warning-face) +(defvar sisu-general-font-lock-red2 font-lock-comment-face) +(defvar sisu-general-font-lock-red3 font-lock-string-face) + +(defvar sisu-general-font-lock-green1 font-lock-type-face) +(defvar sisu-general-font-lock-green2 font-lock-constant-face) + +(defvar sisu-general-font-lock-blue1 font-lock-keyword-face) +(defvar sisu-general-font-lock-blue2 font-lock-function-name-face) +(defvar sisu-general-font-lock-blue3 font-lock-builtin-face) + +(defvar sisu-general-font-lock-yellow1 font-lock-variable-name-face) +(defvar sisu-general-font-lock-yellow2 font-lock-comment-face) + +;; == sisu-spine-mode settings + +(defvar sisu-spine-mode-hook nil + "Normal hook run when entering Sisu Text mode.") + +(defvar sisu-spine-mode-abbrev-table nil + "Abbrev table in use in Sisu-spine-mode buffers.") +(define-abbrev-table 'sisu-spine-mode-abbrev-table ()) + +(defconst sisu-font-lock-keywords + (eval-when-compile + (list + ;;grouped text --------- + ;(cons "^```[ ]code\\(.\\|\n\\)+?\n```\n" 'sisu-general-font-lock-red2) + (cons "^```[ ]+code.*?$\\|^```$" 'sisu-general-font-lock-red2) + (cons "^```[ ]+table.*?$\\|^```$" 'sisu-general-font-lock-red2) + (cons "^```[ ]+group$\\|^```$" 'sisu-general-font-lock-red2) + (cons "^```[ ]+block$\\|^```$" 'sisu-general-font-lock-red2) + (cons "^```[ ]+poem$\\|^```$" 'sisu-general-font-lock-red2) + (cons "^```[ ]+alt$\\|^```$" 'sisu-general-font-lock-red2) + ;;grouped text --------- + (cons "^group{\\|^}group" 'sisu-general-font-lock-red2) + (cons "^block{\\|^}block" 'sisu-general-font-lock-red2) + (cons "^code{\\|^}code" 'sisu-general-font-lock-red2) + (cons "^poem{\\|^}poem" 'sisu-general-font-lock-red2) + (cons "^alt{\\|^}alt" 'sisu-general-font-lock-red2) + (cons "^table{.+\\|^}table" 'sisu-general-font-lock-red2) + (cons "^{table[^}]+}" 'sisu-general-font-lock-red2) + + (list + (concat + "^\`\\{3\\}[ ]+code.*?$" + "\\(.\\|\n\\)+?" + "\`\\{3\\}$" + ) + '(1 sisu-general-font-lock-red2 t) + '(2 nil t) + '(3 sisu-general-font-lock-red2 t) + ) + (list + (concat + "^\`\\{3\\}[ ]+table.*?$" + "\\(.\\|\n\\)+?" + "\`\\{3\\}$" + ) + '(1 sisu-general-font-lock-red2 t) + '(2 nil t) + '(3 sisu-general-font-lock-red2 t) + ) + (list + (concat + "^\`\\{3\\}[ ]+\\(group\\|block\\|alt\\|poem\\)$" + "\\(.\\|\n\\)+?" + "^\`\\{3\\}$" + ) + '(1 sisu-general-font-lock-red2 t) + '(2 nil t) + '(3 sisu-general-font-lock-red2 t) + ) + + ;; footnote/endnote ---- + ;(cons "\~{.+?}\~" 'sisu-general-font-lock-green1) + (cons "\~{\\*\\*\\|\~{\\*\\|\~{\\|}\~" 'sisu-general-font-lock-red2) + (cons "\~\\[\\+\\|\~\\[\\*\\|\~\\[\\|\\]\~" 'sisu-general-font-lock-red2) + (cons "\~\\^ \\|^\\^\~ " 'sisu-general-font-lock-red2) + (list + (concat + "\\(\*\~\\)" + "\\([^ \r\t\n]+\\)" + ) + '(1 sisu-general-font-lock-red1 t) + '(2 sisu-general-font-lock-blue2 t) + ) + + ;; emphasis (can be program configured to be bold italics or underscore) + (list + (concat + "\\([*]{\\)" + "\\([^}]+\\)" + "\\(}[*]\\)" + ) + '(1 sisu-general-font-lock-red1 t) + '(2 sisu-general-font-lock-red1 t) + '(3 sisu-general-font-lock-red1 t) + ) + + ;; bold ---------------- + (list + (concat + "\\([!]{\\)" + "\\([^}]+\\)" + "\\(}[!]\\)" + ) + '(1 sisu-general-font-lock-red1 t) + '(2 sisu-general-font-lock-red1 t) + '(3 sisu-general-font-lock-red1 t) + ) + (cons "\\*[^ ]+\\*" 'sisu-general-font-lock-red1) + (cons "^!_ .+" 'sisu-general-font-lock-red1) + + ;; italics ------------- + (list + (concat + "\\([/]{\\)" + "\\([^}]+\\)" + "\\(}[/]\\)" + ) + '(1 sisu-general-font-lock-red1 t) + '(2 sisu-general-font-lock-blue1 t) + '(3 sisu-general-font-lock-red1 t) + ) + + ;; underscore ---------- + (list + (concat + "\\([_]{\\)" + "\\([^}]+\\)" + "\\(\}[_]\\)" + ) + '(1 sisu-general-font-lock-red1 t) + '(2 sisu-general-font-lock-red1 t) + '(3 sisu-general-font-lock-red1 t) + ) + + ;; monospace ----------- + (list + (concat + "\\([#]{\\)" + "\\([^}]+\\)" + "\\(}[#]\\)" + ) + '(1 sisu-general-font-lock-red1 t) + '(2 sisu-general-font-lock-red1 t) + '(3 sisu-general-font-lock-red1 t) + ) + + ;; citation ------------ + (list + (concat + "\\([\"]{\\)" + "\\([^}]+\\)" + "\\(}[\"]\\)" + ) + '(1 sisu-general-font-lock-red1 t) + '(2 sisu-general-font-lock-red1 t) + '(3 sisu-general-font-lock-red1 t) + ) + + ;; inserted text ------- + (list + (concat + "\\([\+]{\\)" + "\\([^}]+\\)" + "\\(}[\+]\\)" + ) + '(1 sisu-general-font-lock-red1 t) + '(2 sisu-general-font-lock-red1 t) + '(3 sisu-general-font-lock-red1 t) + ) + + ;; strike through ------ + (list + (concat + "\\(\\-{\\)" + "\\([^}]+\\)" + "\\(}\\-\\)" + ) + '(1 sisu-general-font-lock-red1 t) + '(2 sisu-general-font-lock-red1 t) + '(3 sisu-general-font-lock-red1 t) + ) + + ;; superscript --------- + (list + (concat + "\\(\\^{\\)" + "\\([^}]+\\)" + "\\(}\\^\\)" + ) + '(1 sisu-general-font-lock-red1 t) + '(2 sisu-general-font-lock-red1 t) + '(3 sisu-general-font-lock-red1 t) + ) + + ;; subscript ----------- + (list + (concat + "\\([,]{\\)" + "\\([^}]+\\)" + "\\(}[,]\\)" + ) + '(1 sisu-general-font-lock-red1 t) + '(2 sisu-general-font-lock-red1 t) + '(3 sisu-general-font-lock-red1 t) + ) + + ;; numbered list + (cons "^# \\|^_# " 'sisu-general-font-lock-red1) + + ;; bullet text + (cons "^_\\*[1-9] \\|^_\\* " 'sisu-general-font-lock-red1) + + ;; indented text + (cons "^_[1-9] " 'sisu-general-font-lock-red1) + (cons "^_[1-9]! " 'sisu-general-font-lock-red1) + + ;; hanging indented text [proposed enable when implemented] + (cons "^__[1-9] " 'sisu-general-font-lock-red1) + (cons "^_[0-9]_[0-9] " 'sisu-general-font-lock-red1) + (cons "^__[1-9]! " 'sisu-general-font-lock-red1) + (cons "^_[0-9]_[0-9]! " 'sisu-general-font-lock-red1) + + ;; url + (cons "\\(^\\|[ ]\\)https?:[/][/][^ \t\n\r<]+" 'sisu-general-font-lock-blue2) + + ;; Comment Lines + (cons "^% .*" 'sisu-general-font-lock-blue1) + + ;; page break + (cons "^\\(-\\\\\\\\-\\|=\\\\\\\\=\\|-\\.\\.-\\)" 'sisu-general-font-lock-red2) + + ;; line break + (cons " \\\\\\\\ " 'sisu-general-font-lock-red1) + + ;; line break (depreciated) + (cons "
" 'sisu-general-font-lock-red1) + + ;; Section titles + (list "^\\(\\([1-4]\\|:?[A-D]\\)\\~\\)\\(.*\\)" + '(1 sisu-title-1 t) + '(3 sisu-title-2 t) + ) + + ;; hyper-links + (list + (concat + "\\({~^\\|{\\)" + "\\([^}{]+\\)" + "\\(}https?:[/][/][^ \r\n\t<]+\\)" + ) + '(1 sisu-general-font-lock-blue2 t) + '(2 sisu-general-font-lock-red1 t) + '(3 sisu-general-font-lock-blue2 t) + ) + + ;; book index + (list + (concat + "^\\(\={\\)" + "\\([^}{]+\\)" + "\\(}\\)$" + ) + '(1 sisu-general-font-lock-green1 t) + '(2 nil t) + '(3 sisu-general-font-lock-green1 t) + ) + + ;(cons "^\={.+}" 'sisu-general-font-lock-green1) + + ;; numbers + (cons "\\<[.0-9]+\\>" 'sisu-general-font-lock-green2) + + ;; bullets sisu_normal (nearly copied regexp) + (cons "^_\\([1-9*]\\|[1-9]\\*\\) " 'sisu-general-font-lock-blue2) + + ;; image links + (list + (concat + "\\({\\)" + "\\([^}{]+\\)" + "\\(}image\\)" + ) + '(1 sisu-general-font-lock-blue2 t) + '(2 sisu-general-font-lock-red1 t) + '(3 sisu-general-font-lock-blue2 t) + ) + + ;; insert file links + (list + (concat + "\\(<< \\)" + "\\([^ \r\t\n]+\\.ss\\)" + "\\(i\\|t\\)" + ) + '(1 sisu-general-font-lock-blue2 t) + '(2 sisu-general-font-lock-blue2 t) + '(3 sisu-general-font-lock-blue2 t) + ) + + ;; raw keywords + (list + (concat + "^\\(\\(" + "creator\\|" + "title\\|" + "date\\|" + "rights\\|" + "publisher\\|" + "classify\\|" + "identifier\\|" + "original\\|" + "notes\\|" + "links\\|" + "make\\|" + "\\):\\)\\(.*\\)" + ) + '(1 sisu-title-2 keep) + '(3 sisu-title-3 keep) + ) + ) + ) + "Default expressions to highlight in AsciiSisu mode." +) + +;; outline mode evil "folding" if available +;; (define-key evil-normal-state-map ",0" 'show-all) +;; (define-key evil-normal-state-map ",-" 'hide-body) +;; (define-key evil-normal-state-map ",+" 'show-subtree) +;; (define-key evil-normal-state-map ",=" 'show-subtree) + +;; + +;; Sisu & Autoload: + +;;;###autoload +(define-derived-mode sisu-spine-mode text-mode "SiSU" + "Major mode for editing SiSU files. +SiSU document structuring, publishing in multiple formats and search. +URL `http://www.sisudoc.org/'" + (modify-syntax-entry ?\' ".") + ;;(flyspell-mode nil) + + (make-local-variable 'paragraph-start) + (setq paragraph-start (concat "$\\|>" page-delimiter)) + (make-local-variable 'paragraph-separate) + (setq paragraph-separate paragraph-start) + (make-local-variable 'paragraph-ignore-fill-prefix) + (setq paragraph-ignore-fill-prefix t) + + (set (make-local-variable 'outline-regexp) + "^\\(\\([1-4]\\|:?[A-D]\\)\\~\\|\\@[a-z]+:\\( \\|$\\)\\)") + + (make-local-variable 'require-final-newline) + (setq require-final-newline t) + + (make-local-variable 'font-lock-defaults) + (setq font-lock-defaults + '(sisu-font-lock-keywords + nil ; KEYWORDS-ONLY: no + nil ; CASE-FOLD: no + ((?_ . "w")) ; SYNTAX-ALIST + )) + ;; Enable outlining. + ;; TODO with outlining make sure linum (line numbering) is off, + ;; else performance penalty, sucks bigtime + (outline-minor-mode 1)) + +;;;###autoload (add-to-list 'auto-mode-alist '("\\.ss[imt]\\'" . sisu-spine-mode)) + +(provide 'sisu-spine-mode) + +;; + +;;; sisu-spine-mode.el ends here +#+END_SRC diff --git a/org/util_spine_syntax_highlighting_vim.org b/org/util_spine_syntax_highlighting_vim.org new file mode 100644 index 0000000..137d734 --- /dev/null +++ b/org/util_spine_syntax_highlighting_vim.org @@ -0,0 +1,984 @@ +-*- mode: org -*- +#+TITLE: spine (doc_reform) information files +#+DESCRIPTION: documents - structuring, various output representations & search +#+FILETAGS: :spine:info: +#+AUTHOR: Ralph Amissah +#+EMAIL: [[mailto:ralph.amissah@gmail.com][ralph.amissah@gmail.com]] +#+COPYRIGHT: Copyright (C) 2015 - 2020 Ralph Amissah +#+LANGUAGE: en +#+STARTUP: content hideblocks hidestars noindent entitiespretty +#+PROPERTY: header-args :exports code +#+PROPERTY: header-args+ :noweb yes +#+PROPERTY: header-args+ :eval no +#+PROPERTY: header-args+ :results no +#+PROPERTY: header-args+ :cache no +#+PROPERTY: header-args+ :padline no + +* Vim Syntax highlighting +** filetype + +#+BEGIN_SRC text :tangle "../misc/editor-syntax-etc/vim/filetype.vim" +" SiSU filetype file +if exists("did_load_filetypes") + finish +endif +augroup filetypedetect + au! BufNewFile,BufRead *.sst,*.ssm,*.ssi,*.-sst setf sisu + au! BufNewFile,BufRead *._sst,*.sst.meta,*.-sst.meta,*._sst.meta setf sisu +augroup END +#+END_SRC + +** debian vim addon manager + +#+BEGIN_SRC text :tangle "../misc/editor-syntax-etc/vim/vim-sisu.yaml" +#vim-addons: debian vim-addon-manager +addon: sisu +description: SiSU documents - structuring, publishing in multiple formats and search +basedir: /usr/share/vim-scripts/ +files: + - ftplugin/sisu.vim + - syntax/sisu.vim +#+END_SRC + +** color files +*** def.vim + +#+BEGIN_SRC text :tangle "../misc/editor-syntax-etc/vim/colors/def.vim" +" Vim color file +" Name: def +" Maintainer: Ralph Amissah +" Last Change: 2013-02-14 +" URL: +" Note: primarily 16 color cterm improved by tweaking of .Xdefaults +" (with occasional other colors selected from 256 color palate) +" .Xdefaults tweaking to make identical to def (256) provided, +" along with an alternative possibility using colors beyond +" 256 color palate +:hi clear +if exists("syntax_on") + syntax reset +endif +:set t_Co=256 +:set background=dark +:let colors_name = "def" +" ------- +" terminal def +" ------- +:hi Normal ctermbg=0 ctermfg=7 +":hi Cursor ctermbg=5 ctermfg=0 +:hi lCursor cterm=reverse +:hi StatusLine cterm=bold,reverse +:hi StatusLineNC cterm=reverse +:hi Search cterm=none ctermbg=57 ctermfg=0 +:hi IncSearch cterm=none ctermbg=154 ctermfg=0 +:hi SpecialKey ctermfg=4 +:hi Visual cterm=reverse +:hi VisualNOS cterm=bold,underline +:hi MoreMsg ctermfg=2 +:hi ModeMsg cterm=bold +:hi Question ctermfg=2 +:hi Title cterm=bold ctermfg=3 +:hi NonText cterm=bold ctermfg=4 +:hi LineNr cterm=bold ctermbg=0 ctermfg=0* +:hi CursorLineNr cterm=bold ctermbg=166 ctermfg=0 +:hi Directory ctermfg=4 +:hi WildMenu ctermbg=3 ctermfg=0 +:hi VertSplit cterm=reverse +:hi Folded cterm=none ctermbg=0 ctermfg=8 +:hi FoldColumn ctermbg=7 ctermfg=4 +:hi DiffAdd cterm=none ctermbg=2 ctermfg=0 +:hi DiffChange cterm=none ctermbg=7 ctermfg=0 +:hi DiffDelete cterm=none ctermbg=7 ctermfg=0 +:hi DiffText cterm=none ctermbg=6 ctermfg=0 +:hi String cterm=none ctermfg=3 +:hi Comment cterm=none ctermbg=0 ctermfg=4 +:hi Constant ctermfg=1 +:hi Special ctermfg=6 +:hi Identifier ctermfg=6 +:hi Statement ctermfg=2 +:hi Operator ctermfg=2 +:hi PreProc ctermfg=1 +:hi Type cterm=bold ctermfg=3 +:hi Delimiter cterm=none ctermfg=2 +:hi Ignore cterm=bold ctermfg=7 +:hi Todo ctermbg=3 ctermfg=0 +:hi Underlined cterm=underline +:hi Include ctermfg=1 +:hi Define ctermfg=3 +:hi Function ctermfg=6 +:hi Structure ctermfg=2 +:hi MatchParen cterm=bold ctermbg=4 ctermfg=7 +:hi CursorLine cterm=bold +:hi CursorColumn ctermbg=17 +:hi ColorColumn ctermbg=17 +:hi SpellBad cterm=underline ctermbg=0 ctermfg=5 +:hi SpellCap cterm=underline ctermbg=0 ctermfg=5 +:hi SpellLocal cterm=underline ctermbg=0 ctermfg=5 +:hi SpellRare cterm=underline ctermbg=0 ctermfg=5 +:hi TrailingWhitespace ctermbg=1 +:hi ExtraWhitespace ctermbg=1 +:hi WarningMsg ctermfg=1 +:hi ErrorMsg cterm=bold ctermbg=1 ctermfg=7 +:hi Error cterm=bold ctermbg=1 ctermfg=7 +" ------- +" gui def +" ------- +:hi Normal guibg=#000000 guifg=#D3D3D3 +:hi Cursor guibg=#CC9966 guifg=#000000 +:hi lCursor gui=reverse +:hi StatusLine gui=bold,reverse +:hi StatusLineNC gui=reverse +:hi Search gui=none guibg=#5F00FF guifg=#000000 +:hi IncSearch gui=none guibg=#AFFF00 guifg=#000000 +:hi SpecialKey guifg=#5971AD +:hi Visual gui=reverse +:hi VisualNOS gui=bold,underline +:hi MoreMsg guifg=#4E9A06 +:hi ModeMsg gui=bold +:hi Question guifg=#4E9A06 +:hi Title gui=bold guifg=#C4A000 +:hi NonText gui=bold guifg=#5971AD +:hi LineNr gui=bold guibg=#000000 guifg=#808080 +:hi CursorLineNr gui=bold guibg=#D75F00 guifg=#000000 +:hi Directory guifg=#5971AD +:hi WildMenu guibg=#C4A000 guifg=#000000 +:hi VertSplit gui=reverse +:hi Folded gui=none guibg=#000000 guifg=#808080 +:hi FoldColumn guibg=#D3D3D3 guifg=#5971AD +:hi DiffAdd gui=none guibg=#4E9A06 guifg=#000000 +:hi DiffChange gui=none guibg=#D3D3D3 guifg=#000000 +:hi DiffDelete gui=none guibg=#D3D3D3 guifg=#000000 +:hi DiffText gui=none guibg=#06989A guifg=#000000 +:hi String gui=none guifg=#C4A000 +:hi Comment gui=none guibg=#000000 guifg=#5971AD +:hi Constant guifg=#CC0000 +:hi Special guifg=#06989A +:hi Identifier guifg=#06989A +:hi Statement guifg=#4E9A06 +:hi Operator guifg=#4E9A06 +:hi PreProc guifg=#CC0000 +:hi Type gui=bold guifg=#C4A000 +:hi Delimiter gui=none guifg=#4E9A06 +:hi Ignore gui=bold guifg=#D3D3D3 +:hi Todo guibg=#C4A000 guifg=#000000 +:hi Underlined gui=underline +:hi Include guifg=#CC0000 +:hi Define guifg=#C4A000 +:hi Function guifg=#06989A +:hi Structure guifg=#4E9A06 +:hi MatchParen gui=bold guibg=#5971AD guifg=#D3D3D3 +:hi CursorLine gui=bold +:hi CursorColumn guibg=#00005F +:hi ColorColumn guibg=#00005F +:hi SpellBad gui=underline guibg=#000000 guifg=#75507B +:hi SpellCap gui=underline guibg=#000000 guifg=#75507B +:hi SpellLocal gui=underline guibg=#000000 guifg=#75507B +:hi SpellRare gui=underline guibg=#000000 guifg=#75507B +:hi TrailingWhitespace guibg=#080000 +:hi ExtraWhitespace guibg=#CC0000 +:hi WarningMsg guifg=#CC0000 +:hi ErrorMsg gui=bold guibg=#CC0000 guifg=#D3D3D3 +:hi Error gui=bold guibg=#CC0000 guifg=#D3D3D3 +" ------- +"256 color .Xdefaults vim: cterm giu +" +" +" ------- +" 256 color .Xdefaults vim: cterm giu def +" ------- +" 16 color standard altered 256 altered beyond 256 +" black/dark grey +" 0 [ 0:#000000] #000000 +" 8 [ 8:#808080] [59:#5F5F5F] #555555 +" red +" 1 [ 1:#800000] 160:#DF0000 #CC0000 +" 9 [ 9:#FF0000] #EF2929 +" green +" 2 [ 2:#008000] 112:#87DF00 #4E9A06 +" 10 [10:#00FF00] 154:#AFFF00 #8AE234 +" yellow/orange +" 3 [ 3:#808000] 178:#DFAF00 #C4A000 +" 11 [11:#FFFF00] 184:#DFDF00 #FC9E4F +" blue +" 4 [ 4:#000080] 24:#005F87 #5971AD +" 12 [12:#0000FF] 73:#5FAFAF #729FCF +" magenta +" 5 [ 5:#800080] 90:#870087 #75507B +" 13 [13:#FF00FF] 126:#AF0087 #AD7FA8 +" cyan +" 6 [ 6:#008080] 37:#00AFAF #06989A +" 14 [14:#00FFFF] 87:#5FFFFF #34E2E2 +" white +" 7 [ 7:#C0C0C0] #D3D3D3 +" 15 [15:#FFFFFF] #EEEEEE +" -------- +" .Xdefaults (rxvt urxvt setting beyond 256 colors, vim colorscheme "def" gui settings) +" (vim colorscheme "def" cterm matches "def" gui if .Xdefaults set thus) +" -------- +" ! black +" Rxvt.color0 : #000000 +" Rxvt.color8 : #555555 +" ! red +" Rxvt.color1 : #CC0000 +" Rxvt.color9 : #EF2929 +" ! green +" Rxvt.color2 : #4E9A06 +" Rxvt.color10 : #8AE234 +" ! yellow +" Rxvt.color3 : #C4A000 +" Rxvt.color11 : #FCE94F +" ! blue +" Rxvt.color4 : #5971AD +" Rxvt.color12 : #729FCF +" ! magenta +" Rxvt.color5 : #75507B +" Rxvt.color13 : #AD7FA8 +" ! cyan +" Rxvt.color6 : #06989A +" Rxvt.color14 : #34E2E2 +" ! white +" Rxvt.color7 : #D3D7CF +" Rxvt.color15 : #EEEEEE +" -------- +" .Xdefaults 256 (rxvt urxvt setting, vim colorscheme "def256" cterm & gui settings) +" (vim colorscheme "def" cterm matches "def256" if .Xdefaults set thus) +" -------- +" ! black +" Rxvt.color0 : #000000 +" Rxvt.color8 : #808080 +" ! red +" Rxvt.color1 : #DF0000 +" Rxvt.color9 : #FF0000 +" ! green +" Rxvt.color2 : #87DF00 +" Rxvt.color10 : #AFFF00 +" ! yellow +" Rxvt.color3 : #DFAF00 +" Rxvt.color11 : #FFFF00 +" ! blue +" Rxvt.color4 : #5F87DF +" Rxvt.color12 : #87DFFF +" ! magenta +" Rxvt.color5 : #8700DF +" Rxvt.color13 : #87DFFF +" ! cyan +" Rxvt.color6 : #00DFDF +" Rxvt.color14 : #5F5FDF +" ! white +" Rxvt.color7 : #C0C0C0 +" Rxvt.color15 : #FFFFFF +#+END_SRC + +*** slate.vim + +#+BEGIN_SRC text :tangle "../misc/editor-syntax-etc/vim/colors/slate.vim" +"%% SiSU Vim color file +" Name: Slate +" Maintainer: Ralph Amissah +" Last Change: 2013-02-09 +" URL: +" Notes: cterm now uses frugal-sisu 8 colors for term +" (for gui originally looked at desert Hans Fugal +" (April/May 2003)) +:set background=dark +:hi clear +if exists("syntax_on") + syntax reset +endif +:let colors_name = "slate" +" 0 = black, 1 = red, 2 = green, 3 = yellow/orange, 4 = blue, 5 = magenta, 6 = cyan, 7 = white +:hi Normal ctermbg=0 ctermfg=7 guibg=grey15 guifg=white +:hi Cursor term=reverse cterm=reverse guibg=khaki guifg=slategrey +:hi lCursor term=reverse cterm=reverse +:hi StatusLine term=reverse cterm=bold,reverse gui=none guibg=#c2bfa5 guifg=black +:hi StatusLineNC term=reverse cterm=reverse gui=none guibg=#c2bfa5 guifg=grey40 +:hi Search term=reverse cterm=none ctermbg=2 ctermfg=0 guibg=peru guifg=wheat +:hi IncSearch term=reverse cterm=bold ctermbg=2 ctermfg=7 guibg=black guifg=green +:hi SpecialKey term=bold ctermfg=4 guifg=yellowgreen +:hi Visual term=reverse cterm=reverse gui=none guibg=olivedrab guifg=khaki +:hi VisualNOS term=bold,underline cterm=bold,underline +:hi MoreMsg term=bold ctermfg=2 guifg=SeaGreen +:hi ModeMsg term=bold cterm=bold guifg=goldenrod +:hi Question term=standout ctermfg=2 guifg=springgreen +:hi Title term=bold cterm=bold ctermfg=3 gui=bold guifg=gold +:hi NonText term=bold cterm=bold ctermfg=4 guibg=grey15 guifg=RoyalBlue +:hi LineNr term=underline cterm=bold ctermbg=0 ctermfg=0* guifg=grey50 +:hi Directory term=bold ctermfg=4 +:hi WildMenu term=standout ctermbg=3 ctermfg=0 guibg=darkyellow guifg=black +:hi VertSplit term=reverse cterm=reverse gui=none guibg=#c2bfa5 guifg=grey40 +:hi Folded term=standout cterm=none ctermbg=0 ctermfg=7 guibg=black guifg=grey40 +:hi FoldColumn term=standout ctermbg=7 ctermfg=4 guibg=black guifg=grey20 +:hi DiffChange cterm=none ctermbg=7 ctermfg=0 guibg=darkgrey guifg=white +:hi DiffText cterm=none ctermbg=6 ctermfg=0 guibg=darkcyan guifg=white +:hi DiffAdd cterm=none ctermbg=2 ctermfg=0 guibg=darkgreen guifg=white +:hi DiffDelete cterm=none ctermbg=7 ctermfg=0 guibg=darkgrey guifg=black +:hi String cterm=none ctermfg=3 guifg=SkyBlue +:hi Comment term=bold cterm=none ctermbg=0 ctermfg=7 guifg=grey40 +:hi Constant term=underline ctermfg=1 guifg=#ffa0a0 +:hi Special term=bold ctermfg=6 guifg=darkkhaki +:hi Identifier term=underline ctermfg=6 guifg=salmon +:hi Statement term=bold ctermfg=6 guifg=CornflowerBlue +:hi Operator term=bold ctermfg=1 guifg=red +:hi PreProc term=underline ctermbg=7 ctermfg=1 guibg=white guifg=red +:hi Type term=underline ctermfg=2 guifg=CornflowerBlue +:hi Delimiter term=none cterm=none ctermfg=1 +:hi Ignore cterm=bold ctermfg=7 guifg=grey40 +:hi Todo term=standout ctermbg=3 ctermfg=0 guibg=yellow2 guifg=orangered +:hi Underlined term=underline cterm=underline +:hi Include ctermfg=1 guifg=red +:hi Define ctermfg=3 gui=bold guifg=gold +:hi Function ctermfg=6 guifg=navajowhite +:hi Structure ctermfg=2 guifg=green +:hi MatchParen cterm=bold ctermbg=4 ctermfg=7 +:hi CursorLine cterm=bold,underline guibg=black +:hi CursorColumn cterm=bold guibg=black +:hi SpellBad term=underline,standout cterm=none ctermbg=7 ctermfg=0 guibg=darkmagenta guifg=white +:hi SpellCap term=underline,standout cterm=none ctermbg=7 ctermfg=0 +:hi SpellLocal term=underline,standout cterm=none ctermbg=7 ctermfg=0 guibg=darkmagenta guifg=white +:hi SpellRare term=underline,standout cterm=none ctermbg=7 ctermfg=0 +:hi WarningMsg term=standout ctermfg=1 guibg=darkmagenta guifg=salmon +:hi ErrorMsg term=standout cterm=bold ctermbg=1 ctermfg=7 guibg=darkmagenta guifg=white +:hi Error term=reverse cterm=bold ctermbg=1 ctermfg=7 guibg=darkmagenta guifg=white +:hi Black ctermbg=grey ctermfg=black guibg=grey guifg=black +:hi Red ctermbg=black ctermfg=red guibg=black guifg=red +:hi Magenta ctermbg=black ctermfg=magenta guibg=black guifg=magenta +:hi Blue ctermbg=black ctermfg=blue guibg=black guifg=blue +:hi Cyan ctermbg=black ctermfg=cyan guibg=black guifg=cyan +:hi Green ctermbg=black ctermfg=green guibg=black guifg=green +:hi Yellow ctermbg=black ctermfg=yellow guibg=black guifg=yellow +:hi White ctermbg=black ctermfg=white guibg=black guifg=white +#+END_SRC + +*** def-sisu.vim + +#+BEGIN_SRC text :tangle "../misc/editor-syntax-etc/vim/colors/def-sisu.vim" +" Vim color file +" Name: def-sisu +" Maintainer: Ralph Amissah +" Last Change: 2013-02-14 +" URL: +" Note: primarily 16 color cterm improved by tweaking of .Xdefaults +" (with occasional other colors selected from 256 color palate) +" .Xdefaults tweaking to make identical to def (256) provided, +" along with an alternative possibility using colors beyond +" 256 color palate +:hi clear +if exists("syntax_on") + syntax reset +endif +:set t_Co=256 +:set background=dark +:let colors_name = "def-sisu" +" ------- +" terminal def +" ------- +:hi Normal ctermbg=0 ctermfg=7 +":hi Cursor ctermbg=5 ctermfg=0 +:hi lCursor cterm=reverse +:hi StatusLine cterm=bold,reverse +:hi StatusLineNC cterm=reverse +:hi Search cterm=none ctermbg=57 ctermfg=0 +:hi IncSearch cterm=none ctermbg=154 ctermfg=0 +:hi SpecialKey ctermfg=4 +:hi Visual cterm=reverse +:hi VisualNOS cterm=bold,underline +:hi MoreMsg ctermfg=2 +:hi ModeMsg cterm=bold +:hi Question ctermfg=2 +:hi Title cterm=bold ctermfg=3 +:hi NonText cterm=bold ctermfg=4 +:hi LineNr cterm=bold ctermbg=0 ctermfg=0* +:hi CursorLineNr cterm=bold ctermbg=166 ctermfg=0 +:hi Directory ctermfg=4 +:hi WildMenu ctermbg=3 ctermfg=0 +:hi VertSplit cterm=reverse +:hi Folded cterm=none ctermbg=0 ctermfg=8 +:hi FoldColumn ctermbg=7 ctermfg=4 +:hi DiffAdd cterm=none ctermbg=2 ctermfg=0 +:hi DiffChange cterm=none ctermbg=7 ctermfg=0 +:hi DiffDelete cterm=none ctermbg=7 ctermfg=0 +:hi DiffText cterm=none ctermbg=6 ctermfg=0 +:hi String cterm=none ctermfg=3 +:hi Comment cterm=none ctermbg=0 ctermfg=4 +:hi Constant ctermfg=1 +:hi Special ctermfg=6 +:hi Identifier ctermfg=6 +:hi Statement ctermfg=6 +:hi Operator ctermfg=1 +:hi PreProc ctermbg=7 ctermfg=1 +:hi Type ctermfg=2 +:hi Delimiter cterm=none ctermfg=1 +:hi Ignore cterm=bold ctermfg=7 +:hi Todo ctermbg=3 ctermfg=0 +:hi Underlined cterm=underline +:hi Include ctermfg=1 +:hi Define ctermfg=3 +:hi Function ctermfg=6 +:hi Structure ctermfg=2 +:hi MatchParen cterm=bold ctermbg=4 ctermfg=7 +:hi CursorLine cterm=bold +:hi CursorColumn ctermbg=17 +:hi ColorColumn ctermbg=17 +:hi SpellBad cterm=underline ctermbg=0 ctermfg=5 +:hi SpellCap cterm=underline ctermbg=0 ctermfg=5 +:hi SpellLocal cterm=underline ctermbg=0 ctermfg=5 +:hi SpellRare cterm=underline ctermbg=0 ctermfg=5 +:hi TrailingWhitespace ctermbg=1 +:hi ExtraWhitespace ctermbg=1 +:hi WarningMsg ctermfg=1 +:hi ErrorMsg cterm=bold ctermbg=1 ctermfg=7 +:hi Error cterm=bold ctermbg=1 ctermfg=7 +" ------- +" gui def +" ------- +:hi Normal guibg=#000000 guifg=#D3D3D3 +:hi Cursor guibg=#CC9966 guifg=#000000 +:hi lCursor gui=reverse +:hi StatusLine gui=bold,reverse +:hi StatusLineNC gui=reverse +:hi Search gui=none guibg=#5F00FF guifg=#000000 +:hi IncSearch gui=none guibg=#AFFF00 guifg=#000000 +:hi SpecialKey guifg=#5971AD +:hi Visual gui=reverse +:hi VisualNOS gui=bold,underline +:hi MoreMsg guifg=#4E9A06 +:hi ModeMsg gui=bold +:hi Question guifg=#4E9A06 +:hi Title gui=bold guifg=#C4A000 +:hi NonText gui=bold guifg=#5971AD +:hi LineNr gui=bold guibg=#000000 guifg=#808080 +:hi CursorLineNr gui=bold guibg=#D75F00 guifg=#000000 +:hi Directory guifg=#5971AD +:hi WildMenu guibg=#C4A000 guifg=#000000 +:hi VertSplit gui=reverse +:hi Folded gui=none guibg=#000000 guifg=#808080 +:hi FoldColumn guibg=#D3D3D3 guifg=#5971AD +:hi DiffAdd gui=none guibg=#4E9A06 guifg=#000000 +:hi DiffChange gui=none guibg=#D3D3D3 guifg=#000000 +:hi DiffDelete gui=none guibg=#D3D3D3 guifg=#000000 +:hi DiffText gui=none guibg=#06989A guifg=#000000 +:hi String gui=none guifg=#C4A000 +:hi Comment gui=none guibg=#000000 guifg=#5971AD +:hi Constant guifg=#CC0000 +:hi Special guifg=#06989A +:hi Identifier guifg=#06989A +:hi Statement guifg=#06989A +:hi Operator guifg=#CC0000 +:hi PreProc guibg=#D3D3D3 guifg=#CC0000 +:hi Type guifg=#4E9A06 +:hi Delimiter gui=none guifg=#CC0000 +:hi Ignore gui=bold guifg=#D3D3D3 +:hi Todo guibg=#C4A000 guifg=#000000 +:hi Underlined gui=underline +:hi Include guifg=#CC0000 +:hi Define guifg=#C4A000 +:hi Function guifg=#06989A +:hi Structure guifg=#4E9A06 +:hi MatchParen gui=bold guibg=#5971AD guifg=#D3D3D3 +:hi CursorLine gui=bold +:hi CursorColumn guibg=#00005F +:hi ColorColumn guibg=#00005F +:hi SpellBad gui=underline guibg=#000000 guifg=#75507B +:hi SpellCap gui=underline guibg=#000000 guifg=#75507B +:hi SpellLocal gui=underline guibg=#000000 guifg=#75507B +:hi SpellRare gui=underline guibg=#000000 guifg=#75507B +:hi TrailingWhitespace guibg=#080000 +:hi ExtraWhitespace guibg=#CC0000 +:hi WarningMsg guifg=#CC0000 +:hi ErrorMsg gui=bold guibg=#CC0000 guifg=#D3D3D3 +:hi Error gui=bold guibg=#CC0000 guifg=#D3D3D3 +" ------- +"256 color .Xdefaults vim: cterm giu +" +" +" ------- +" 256 color .Xdefaults vim: cterm giu def +" ------- +" 16 color standard altered 256 altered beyond 256 +" black/dark grey +" 0 [ 0:#000000] #000000 +" 8 [ 8:#808080] [59:#5F5F5F] #555555 +" red +" 1 [ 1:#800000] 160:#DF0000 #CC0000 +" 9 [ 9:#FF0000] #EF2929 +" green +" 2 [ 2:#008000] 112:#87DF00 #4E9A06 +" 10 [10:#00FF00] 154:#AFFF00 #8AE234 +" yellow/orange +" 3 [ 3:#808000] 178:#DFAF00 #C4A000 +" 11 [11:#FFFF00] 184:#DFDF00 #FC9E4F +" blue +" 4 [ 4:#000080] 24:#005F87 #5971AD +" 12 [12:#0000FF] 73:#5FAFAF #729FCF +" magenta +" 5 [ 5:#800080] 90:#870087 #75507B +" 13 [13:#FF00FF] 126:#AF0087 #AD7FA8 +" cyan +" 6 [ 6:#008080] 37:#00AFAF #06989A +" 14 [14:#00FFFF] 87:#5FFFFF #34E2E2 +" white +" 7 [ 7:#C0C0C0] #D3D3D3 +" 15 [15:#FFFFFF] #EEEEEE +" -------- +" .Xdefaults (rxvt urxvt setting beyond 256 colors, vim colorscheme "def" gui settings) +" (vim colorscheme "def" cterm matches "def" gui if .Xdefaults set thus) +" -------- +" ! black +" Rxvt.color0 : #000000 +" Rxvt.color8 : #555555 +" ! red +" Rxvt.color1 : #CC0000 +" Rxvt.color9 : #EF2929 +" ! green +" Rxvt.color2 : #4E9A06 +" Rxvt.color10 : #8AE234 +" ! yellow +" Rxvt.color3 : #C4A000 +" Rxvt.color11 : #FCE94F +" ! blue +" Rxvt.color4 : #5971AD +" Rxvt.color12 : #729FCF +" ! magenta +" Rxvt.color5 : #75507B +" Rxvt.color13 : #AD7FA8 +" ! cyan +" Rxvt.color6 : #06989A +" Rxvt.color14 : #34E2E2 +" ! white +" Rxvt.color7 : #D3D7CF +" Rxvt.color15 : #EEEEEE +" -------- +" .Xdefaults 256 (rxvt urxvt setting, vim colorscheme "def256" cterm & gui settings) +" (vim colorscheme "def" cterm matches "def256" if .Xdefaults set thus) +" -------- +" ! black +" Rxvt.color0 : #000000 +" Rxvt.color8 : #808080 +" ! red +" Rxvt.color1 : #DF0000 +" Rxvt.color9 : #FF0000 +" ! green +" Rxvt.color2 : #87DF00 +" Rxvt.color10 : #AFFF00 +" ! yellow +" Rxvt.color3 : #DFAF00 +" Rxvt.color11 : #FFFF00 +" ! blue +" Rxvt.color4 : #5F87DF +" Rxvt.color12 : #87DFFF +" ! magenta +" Rxvt.color5 : #8700DF +" Rxvt.color13 : #87DFFF +" ! cyan +" Rxvt.color6 : #00DFDF +" Rxvt.color14 : #5F5FDF +" ! white +" Rxvt.color7 : #C0C0C0 +" Rxvt.color15 : #FFFFFF +#+END_SRC + +*** frugal-cterm.vim + +#+BEGIN_SRC text :tangle "../misc/editor-syntax-etc/vim/colors/frugal-cterm-sisu.vim" +" Vim color file +" Name: frugal-cterm-sisu +" Maintainer: Ralph Amissah +" Last Change: 2013-02-09 +" URL: +" Note: 8 color cterm, related colorschemes 8 & sparse +:set background=dark +:hi clear +if exists("syntax_on") + syntax reset +endif +:let colors_name = "frugal-cterm-sisu" +" 0 = black, 1 = red, 2 = green, 3 = yellow/orange, 4 = blue, 5 = magenta, 6 = cyan, 7 = white +:hi Normal ctermbg=0 ctermfg=7 +:hi Cursor cterm=reverse +:hi lCursor cterm=reverse +:hi StatusLine cterm=bold,reverse +:hi StatusLineNC cterm=reverse +:hi Search cterm=none ctermbg=2 ctermfg=0 +:hi IncSearch cterm=bold ctermbg=2 ctermfg=7 +:hi SpecialKey ctermfg=4 +:hi Visual cterm=reverse +:hi VisualNOS cterm=bold,underline +:hi MoreMsg ctermfg=2 +:hi ModeMsg cterm=bold +:hi Question ctermfg=2 +:hi Title cterm=bold ctermfg=3 +:hi NonText cterm=bold ctermfg=4 +:hi LineNr cterm=bold ctermbg=0 ctermfg=0* +:hi Directory ctermfg=4 +:hi WildMenu ctermbg=3 ctermfg=0 +:hi VertSplit cterm=reverse +:hi Folded cterm=none ctermbg=0 ctermfg=7 +:hi FoldColumn ctermbg=7 ctermfg=4 +:hi DiffChange cterm=none ctermbg=7 ctermfg=0 +:hi DiffText cterm=none ctermbg=6 ctermfg=0 +:hi DiffAdd cterm=none ctermbg=2 ctermfg=0 +:hi DiffDelete cterm=none ctermbg=7 ctermfg=0 +:hi String cterm=none ctermfg=3 +:hi Comment cterm=none ctermbg=0 ctermfg=7 +:hi Constant ctermfg=1 +:hi Special ctermfg=6 +:hi Identifier ctermfg=6 +:hi Statement ctermfg=6 +:hi Operator ctermfg=1 +:hi PreProc ctermbg=7 ctermfg=1 +:hi Type ctermfg=2 +:hi Delimiter cterm=none ctermfg=1 +:hi Ignore cterm=bold ctermfg=7 +:hi Todo ctermbg=3 ctermfg=0 +:hi Underlined cterm=underline +:hi Include ctermfg=1 +:hi Define ctermfg=3 +:hi Function ctermfg=6 +:hi Structure ctermfg=2 +:hi MatchParen cterm=bold ctermbg=4 ctermfg=7 +:hi CursorLine cterm=bold,underline +:hi CursorColumn cterm=bold +:hi ColorColumn ctermbg=8 +:hi SpellBad cterm=none ctermbg=7 ctermfg=0 +:hi SpellCap cterm=none ctermbg=7 ctermfg=0 +:hi SpellLocal cterm=none ctermbg=7 ctermfg=0 +:hi SpellRare cterm=none ctermbg=7 ctermfg=0 +:hi WarningMsg ctermfg=1 +:hi ErrorMsg cterm=bold ctermbg=1 ctermfg=7 +:hi Error cterm=bold ctermbg=1 ctermfg=7 +#+END_SRC + +** ftplugin sisu.vim + +#+BEGIN_SRC text :tangle "../misc/editor-syntax-etc/vim/ftplugin/sisu.vim" +"%% SiSU Vim ftplugin +" SiSU Maintainer: Ralph Amissah +" SiSU Markup: SiSU (sisu-3.3) 2012-08-18 +" an ftplugin setting defaults for editing sisu markup files +:syntax on +:filetype off +":filetype on +:filetype indent on +:autocmd FileType sisu :set nonumber +:set encoding=utf-8 fileencodings= +:set ff=unix +:set autowrite " Automatically save before commands like :next and :make +:set nocompatible +:set tabstop=2 +:set expandtab +:set shiftwidth=2 +:set autoindent +:set showcmd " Show (partial) command in status line. +:set showmatch " Show matching brackets. +:set ignorecase " Do case insensitive matching +:set smartcase +:set incsearch +:set hlsearch +:set gdefault +:set guioptions=agr " add 'm' for menu +:map :if &guioptions =~# 'm' + \set guioptions-=m + \set guioptions-=T + \else + \set guioptions+=m + \set guioptions-=T + \endif +:set paste +""% statusline +"set statusline= " +"set fillchars=stl:―,stlnc:—,vert:│,fold:۰,diff:· +"" [ buffer number ] +"set statusline +=%#Normal#[ " +"set statusline +=%#Identifier#%n " buffer number +"set statusline +=%#PreProc#%M " modified flag +"set statusline +=%#Normal#] " +"" [ file name (& modified?) ] +"set statusline +=%#Normal#\ [ " +"set statusline +=%#Statement#%<%F%* " full path +""set statusline +=%#Statement#%<%t " full path +"set statusline +=%#PreProc#%M " modified flag +"set statusline +=%#Normal#] " +"" [ column : line number / number of lines in file, percentage of file ] [%v:%l/%L\ %p%%] +"set statusline +=%#Normal#\ [ " +"set statusline +=%#Identifier#%v " column & line +"set statusline +=%#Normal#: " +"set statusline +=%#Identifier#%l " column & line +"set statusline +=%#SpecialKey#/%L\ " total lines +"set statusline +=%#Identifier#%p " percentage of file +"set statusline +=%#SpecialKey#%% " +"set statusline +=%#Normal#] " " +"" [ file format : file type ] +"set statusline +=%#Normal#\ [ " +"set statusline +=%#SpecialKey#%{&fenc} " file format +"set statusline +=%#Normal#: " +"set statusline +=%#SpecialKey#%{&ff} " file format +"set statusline +=%#Normal#: " +"set statusline +=%#SpecialKey#%y " file type +"set statusline +=%#Normal#] " +"" [ character under cursor ] +"set statusline +=%#Normal#\ [ " +"set statusline +=%#String#0x%04B " character under cursor +"set statusline +=%#Normal#]\ " +"" [ syntastic ] +"set statusline +=%#warningmsg# +"set statusline +=%{SyntasticStatuslineFlag()}\ " +""set statusline+=%* +"" Status line background +"set statusline +=%#Folded#\ " +"" misc +"set laststatus=2 " status line always on +"% textwrap +:set whichwrap=<,>,h,l,[,] +:set nolinebreak " only affects display not buffer +:set wrap +:set wrapmargin=0 +"% map +":let mapleader = "," " consider +:map paste :set invpaste +"% wrap/formatting paragraph according to the current 'textwidth' with ^\ (control-\): +:imap gqap +:nmap gqap +:vmap gq +"% save file, go to next file in buffer +:map nf :w :n +"% vimdiff q exits +:if &diff +: cmap q qa +:endif +"% directory files, placed in vertical split window +:map ls :vs :Explore +:map dir :vs :Explore +"% remapping lines make cursor jump a line at a time within wrapped text +:nnoremap j gj +:nnoremap k gk +:vnoremap j gj +:vnoremap k gk +:nnoremap gj +:nnoremap gk +:vnoremap gj +:vnoremap gk +:inoremap gj +:inoremap gk +"% search and replace +:map rd :.,$s///c "search and replace down +:map rg :%s///c "search and replace whole file +:map rr :rubyd gsub!(//,"") +"% pwd t64 working directory set to that of the file you're editing +"changes pwd to directory of file in current buffer +:function! CHANGE_CURR_DIR() +: let _dir = expand("%:p:h") +: exec "cd " . _dir +: unlet _dir +:endfunction +"% Change to the directory the file in your current buffer is in +:if has("autocmd") + autocmd BufEnter * :lcd %:p:h +:endif +"% autocompletefilenames To search for files in the current directory +:set path=,, +"auto-completion for file to edit in current dir, used in normal mode +:map e :e =expand("%:p:h") . "/" +:map pwd :exe 'cd ' . expand ("%:p:h") +"% searchhighlight t93: Toggle search highlight +:function! ToggleHLSearched() +: if &hls +: set nohls +: else +: set hls +: endif +:endfun +:nmap :silent call ToggleHLSearched() +"%% SiSU vim folds +"% foldsearchx FoldSearch (opens result of search all else closed) t77 +:map fs :set foldmethod=expr foldcolumn=2 foldlevel=0 +:map ff :F +:map fe :F zE +"% foldtoggle Fold Toggle mapped to +:fun! ToggleFold() +: if foldlevel('.') == 0 +: normal! l +: else +: if foldclosed('.') < 0 +: foldclose +: else +: foldopen +: endif +: endif +" Clear status line +: echo +:endfun +" Map this function to Space key. +:noremap :call ToggleFold() +"% foldtype Fold? set foldtext +:set foldtext=v:folddashes.substitute(getline(v:foldstart),'\\=','','g',) +:set foldexpr=getline(v:lnum-1)!~@/&&getline(v:lnum)!~@/&&getline(v:lnum+1)!~@/ +"% foldsearch t77: Fold on search result +:function! FoldMake(search) +: set fdm=manual +: normal zE +: normal G$ +: let folded = 0 "flag to set when a fold is found +: let flags = "w" "allow wrapping in the search +: let line1 = 0 "set marker for beginning of fold +: while search(a:search, flags) > 0 +: let line2 = line(".") +: if (line2 -1 > line1) +: "echo line1 . ":" . (line2-1) +: "echo "a fold goes here." +: execute ":" . line1 . "," . (line2-1) . "fold" +: let folded = 1 "at least one fold has been found +: endif +: let line1 = line2 "update marker +: let flags = "W" "turn off wrapping +: endwhile +" create the last fold which goes to the end of the file. +: normal $G +: let line2 = line(".") +: if (line2 > line1 && folded == 1) +: execute ":". line1 . "," . line2 . "fold" +: endif +: normal 1G +:endfunction +"% folds Fold Patterns +:command! -nargs=+ -complete=command FMake call FoldMake() +: if ( &filetype == "ruby" ) +: command! F FMake ^# ==\?\|^\s*\(\(def\|class\|module\)\s\|\(public\|protected\|private\|__END__\)\s*$\)\|\(^\s*\|\s\+\)#%\s +: command! Fa FMake \(^# ==\?\|^\s*\(\(\(def\|class\|module\)\s\)\|\(\(public\|protected\|private\|__END__\)\(\s*$\)\)\)\)\|^[0-9]\~\|\([#%]\|^["]\)\{1,4\}\s*%\|{\({\|!!\) +: command! FD FMake \(^# ==\?\|^\s*\(\(def\|class\|module\)\s\)\)\|^\s*\([#%"0-9]\{0,4\}\~\(%\+\s\|!!\)\|#\s\+=\+\s\+\) +: else +"% folds :F Fold Patterns SiSU Markup :F +: command! F FMake ^\([1-8]\|:\?[A-C]\)\~\|\(^%\|\(^\|\s\+\)[#"]\)%\{1,2\}\(\s\|$\)\|^<<\s*| +: command! Fa FMake ^\([1-8]\|:\?[A-C]\)\~\|\(^%\|\(^\|\s\+\)[#"]\)%\{1,2\}\(\s\|$\)\|^<<\s*|\|^\(Book\|Part\|Chapter\|Section\|Article\|BOOK\|PART\|CHAPTER\|SECTION\|ARTICLE\)\s +: command! F0 FMake ^\(\s*0\~\|@\S\+:[+-]\?\s\+\) +: command! FA FMake ^:\?A\~ +: command! FB FMake ^:\?[AB]\~ +: command! FC FMake ^:\?[A-C]\~ +: command! F1 FMake ^\(:\?[A-C]\|1\)\~ +: command! F2 FMake ^\(:\?[A-C]\|[12]\)\~ +: command! F3 FMake ^\(:\?[A-C]\|[1-3]\)\~ +: command! F4 FMake ^[1-4]\~ +: command! F5 FMake ^[4-5]\~ +: command! F6 FMake ^[4-6]\~ +: command! Fc FMake ^[%]\+\s\+ +: endif +"% folds Fold Patterns misc +":command! Fp FMake ^\s*[A-Za-z0-9#] +:command! Fp FMake ^\s*\S +:command! Fo FMake ^[%\"]\s*[{>] +"% linenumbering, on, relative, off +:map nn :set ={'00':'','01':'r','10':'nor'}[&rnu.&nu]nu +"% cursorline +:map cu :if &cursorcolumn + \set nocursorline nocursorcolumn + \else + \set cursorline cursorcolumn + \endif +:map cu- :set nocursorline nocursorcolumn +:map cu+ :set cursorline cursorcolumn +#+END_SRC + +** templates +*** sst.tpl + +#+BEGIN_SRC text :tangle "../misc/editor-syntax-etc/vim/templates/sst.tpl" +# SiSU 8.0 + +title: + main: "#___#" + sub: "#___#" + language: "#___#" + +creator: + author: "#___#" + +date: + :published: "YYYY-MM-DD" + +rights: + copyright: "#___#" + license: "#___#" + +classify: + topic_register: "#___#" + +make: + breaks: "new=:B; break=1" +# home_button_text: "#___#" +# footer: "#___#" + +#% -- body --- + +:A~ @title @author + +1~ #___# +#+END_SRC + +*** ssm.tpl + +#+BEGIN_SRC text :tangle "../misc/editor-syntax-etc/vim/templates/ssm.tpl" +# SiSU 8.0 master + +title: + main: "#___#" + sub: "#___#" + language: "#___#" + +creator: + author: "#___#" + +date: + :published: "YYYY-MM-DD" + +rights: + copyright: "#___#" + license: "#___#" + +classify: + topic_register: "#___#" + +make: + breaks: "new=:B; break=1" +# home_button_text: "#___#" +# footer: "#___#" + +#% -- body --- + +:A~ @title @author + +1~ #___# +#+END_SRC + +*** ssm.tpl + +#+BEGIN_SRC text :tangle "../misc/editor-syntax-etc/vim/templates/ssi.tpl" +# SiSU 8.0 insert + +title: + main: "#___#" + sub: "#___#" + language: "#___#" + +creator: + author: "#___#" + +date: + :published: "YYYY-MM-DD" + +rights: + copyright: "#___#" + license: "#___#" + +classify: + topic_register: "#___#" + +make: + breaks: "new=:B; break=1" +# home_button_text: "#___#" +# footer: "#___#" + +#% -- body --- + +:A~ @title @author + +1~ #___# +#+END_SRC -- cgit v1.2.3