diff options
| -rwxr-xr-x[-rw-r--r--] | .envrc | 1 | ||||
| -rwxr-xr-x[-rw-r--r--] | .envrc-git-init | 1 | ||||
| -rwxr-xr-x[-rw-r--r--] | .envrc-local_ | 4 | ||||
| -rwxr-xr-x[-rw-r--r--] | .envrc-nix | 5 | ||||
| -rw-r--r-- | flake.lock | 6 | ||||
| -rw-r--r-- | flake.nix | 34 | ||||
| -rw-r--r-- | org/config_env.org | 13 | ||||
| -rw-r--r-- | org/config_nix.org | 34 | ||||
| -rw-r--r-- | org/default_regex.org | 1 | ||||
| -rw-r--r-- | org/out_text.org | 65 | ||||
| -rw-r--r-- | org/spine.org | 4 | ||||
| -rw-r--r-- | src/sisudoc/io_out/rgx.d | 1 | ||||
| -rw-r--r-- | src/sisudoc/io_out/text.d | 65 | ||||
| -rw-r--r-- | src/sisudoc/meta/rgx.d | 1 | ||||
| -rwxr-xr-x | src/sisudoc/spine.d | 4 |
15 files changed, 126 insertions, 113 deletions
@@ -1,3 +1,4 @@ +# -*- mode: sh -*- if [ -f .envrc-git-init ]; then source_env_if_exists .envrc-git-init || source .envrc-git-init fi diff --git a/.envrc-git-init b/.envrc-git-init index ca74ec3..d78e46b 100644..100755 --- a/.envrc-git-init +++ b/.envrc-git-init @@ -1,3 +1,4 @@ +# -*- mode: sh -*- if [[ ! -d ./.git ]]; then git init git add . diff --git a/.envrc-local_ b/.envrc-local_ index 9c3d071..85c5b09 100644..100755 --- a/.envrc-local_ +++ b/.envrc-local_ @@ -1,3 +1,4 @@ +# -*- mode: sh -*- export SpineVER=$(git describe --long --tags | sed 's/^[ a-z_-]\+\([0-9.]\+\)/\1/;s/\([^-]*-g\)/r\1/;s/-/./g') export SpineBIN=./result/bin/spine # ❯❯ nix builds spine binary: @@ -8,8 +9,9 @@ export SpineBIN=./result/bin/spine #export SpineBIN=./bin/spine-dmd # ❯❯ location of source files: export SpineDOC=../sisudoc-spine-samples +#export SpineDOC=./sisudoc-spine-samples # ❯❯ location of source files pod: -export SpinePOD=${SpineDOC}/markup/pod +export SpinePOD=${SpineDOC}/markup/pod-samples/pod # ❯❯ sisudoc-spine output processing path: export SpineOUT=./OUTPUT_TEST_sisudocSpine # ❯❯ sisudoc-spine output processing path (web server e.g.): diff --git a/.envrc-nix b/.envrc-nix index 5f9d33b..443b5ad 100644..100755 --- a/.envrc-nix +++ b/.envrc-nix @@ -1,3 +1,4 @@ +# -*- mode: nix -*- NIX_ENFORCE_PURITY=1 # - https://github.com/nix-community/nix-direnv NixDirEnvVersion="3.0.7" @@ -65,9 +66,9 @@ echo ' ❯❯ ${SpineBIN} -v --source --pod --latex --latex-init --epub --html --html-link-pdf --html-link-curate --html-link-markup --curate --output=${SpineOUT} ${SpinePOD}/* ❯❯ ${SpineBIN} -v --sqlite-db-create --sqlite-db-filename=${SpineSQLdb} --sqlite-db-path=./_tmp-db - ❯❯ ${SpineBIN} -v --sqlite-update --sqlite-db-filename=${SpineSQLdb} --sqlite-db-path=./_tmp-db ./markup/pod/* + ❯❯ ${SpineBIN} -v --sqlite-update --sqlite-db-filename=${SpineSQLdb} --sqlite-db-path=./_tmp-db ${SpinePOD}/* - ❯❯ $SpineBIN --source --pod --curate --text --latex --epub --html --manifest --html-link-search --html-link-pdf --html-link-text --html-link-curate --html-link-markup --html-link-source --html-link-pod --html-link-metadata --cgi-sqlite-search-filename="$SpineCGIform" --cgi-url-action="$SpineSearchActionRemote" --sqlite-db-path="$SpineDBpath" --sqlite-db-filename="$SpineSQLdb" --www-url-doc-root=$SpineURLdocRoot --set-papersize="a4,letter" --output=$SpineOUT $SpinePOD/* + ❯❯ ${SpineBIN} --source --pod --curate --text --latex --epub --html --manifest --html-link-search --html-link-pdf --html-link-text --html-link-curate --html-link-markup --html-link-source --html-link-pod --html-link-metadata --cgi-sqlite-search-filename="${SpineCGIform}" --cgi-url-action="${SpineSearchActionRemote}" --sqlite-db-path="${SpineDBpath}" --sqlite-db-filename="${SpineSQLdb}" --www-url-doc-root=${SpineURLdocRoot} --set-papersize="a4,letter" --output=${SpineOUT} ${SpinePOD}/* ' echo "• ❯❯ ${SpineBIN} -v --source --pod --epub --html --html-link-curate --html-link-markup --curate --output=${SpineOUT} ${SpinePOD}/* @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1760256791, - "narHash": "sha256-uTpzDHRASEDeFUuToWSQ46Re8beXyG9dx4W36FQa0/c=", + "lastModified": 1761880412, + "narHash": "sha256-QoJjGd4NstnyOG4mm4KXF+weBzA2AH/7gn1Pmpfcb0A=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "832e3b6db48508ae436c2c7bfc0cf914eac6938e", + "rev": "a7fc11be66bdfb5cdde611ee5ce381c183da8386", "type": "github" }, "original": { @@ -34,7 +34,8 @@ inherit system; }; preBuild = '' - export HOME=$(pwd) + export HOME=$TMPDIR + #export HOME=$(pwd) ''; installPhase = '' runHook preInstall @@ -45,6 +46,7 @@ postInstall = '' echo "❯❯ ./result/bin/spine -v --source --pod --text --epub --html --html-link-pdf --html-link-curate --html-link-markup --curate --output=./OUTPUT_TEST_sisudocSpine ../sisu-spine-samples/markup/pod/*"; echo `ls -la $out/bin/spine` + echo "❯❯ spine-v${version} (rev: ${self.shortRev or "unknown"})" $out/bin/spine -v ''; in { @@ -209,13 +211,15 @@ pkgs-ovl = pkgsForSystem system; pkgs-nix = nixpkgsFor.${system}; shellHook = '' - export Date=`date "+%Y%m%d"` + #export Date=`date "+%Y%m%d"` ## set local values in .envrc-local (or here if you must) echo '❯❯ nix build'; - SpineProjVer=`rg "Version\((\d+), (\d+), (\d+)\)" views/version.txt | sed -E 's/.*([0-9]+), ([0-9]+), ([0-9]+).*/spine-v\1.\2.\3/'` && \ - SpineGitVer=`git describe | sed "s/^[a-z_-]\+\([0-9.]\+\)/\1/" | sed "s/\([^-]*-g\)/r\1/" | sed "s/-/./g"` && \ - SpineGitBranch=`git branch --show-current` && \ - echo "❯❯ $SpineProjVer - ($SpineGitBranch: $SpineGitVer)" + ## ImPure Nix environment + SpineGitVer=`git describe | sed "s/^[a-z_-]\+\([0-9.]\+\)/\1/" | sed "s/\([^-]*-g\)/r\1/" | sed "s/-/./g"` && \ + SpineGitBranch=`git branch --show-current` && \ + echo "❯❯ spine-v${version} - ($SpineGitBranch: $SpineGitVer)" + ## Pure Nix environment - version info from flake inputs + #echo "❯❯ spine-v${version} (rev: ${self.shortRev or "unknown"})" echo '❯❯ $SpineBIN -v --source --pod --text --epub --html --html-link-pdf --html-link-curate --html-link-markup --curate --output=$SpineOUT $SpinePOD/*'; echo "❯❯ $SpineBIN -v --source --pod --text --epub --html --html-link-pdf --html-link-curate --html-link-markup --curate --output=$SpineOUT $SpinePOD/*"; echo '❯❯ nix flake update && nix flake check && nix flake show'; @@ -233,7 +237,7 @@ dtools gnumake sqlite - gnused + gnugrep gnused ripgrep ]; inherit shellHook; @@ -248,7 +252,7 @@ dtools gnumake sqlite - gnused + gnugrep gnused ripgrep ]; inherit shellHook; @@ -263,7 +267,7 @@ dtools gnumake sqlite - gnused + gnugrep gnused ripgrep ]; inherit shellHook; @@ -278,7 +282,7 @@ dtools gnumake sqlite - gnused + gnugrep gnused ripgrep ]; inherit shellHook; @@ -322,7 +326,7 @@ calibre #(suite includes: ebook-viewer) koreader foliate - gnused + gnugrep gnused ripgrep ]; inherit shellHook; @@ -345,7 +349,7 @@ w3m # ❯❯ light graphical #dillo - gnused + gnugrep gnused ripgrep ]; inherit shellHook; @@ -364,7 +368,7 @@ source-serif-pro source-code-pro texlive.combined.scheme-full - gnused + gnugrep gnused ripgrep ]; inherit shellHook; @@ -380,7 +384,7 @@ dtools gnumake sqlite - gnused + gnugrep gnused ripgrep ]; inherit shellHook; @@ -397,7 +401,7 @@ gnumake sqlite perl538Packages.Po4a - gnused + gnugrep gnused ripgrep ]; inherit shellHook; diff --git a/org/config_env.org b/org/config_env.org index 3e622ee..2fa1f25 100644 --- a/org/config_env.org +++ b/org/config_env.org @@ -33,6 +33,7 @@ fi #+NAME: envrc #+HEADER: :tangle ../.envrc +#+HEADER: :shebang "# -*- mode: sh -*-" #+BEGIN_SRC shell if [ -f .envrc-git-init ]; then source_env_if_exists .envrc-git-init || source .envrc-git-init @@ -55,6 +56,7 @@ fi - ${NixDirEnvVersion} #+HEADER: :tangle ../.envrc-nix +#+HEADER: :shebang "# -*- mode: nix -*-" #+BEGIN_SRC shell NIX_ENFORCE_PURITY=1 # - https://github.com/nix-community/nix-direnv @@ -123,9 +125,9 @@ echo ' ❯❯ ${SpineBIN} -v --source --pod --latex --latex-init --epub --html --html-link-pdf --html-link-curate --html-link-markup --curate --output=${SpineOUT} ${SpinePOD}/* ❯❯ ${SpineBIN} -v --sqlite-db-create --sqlite-db-filename=${SpineSQLdb} --sqlite-db-path=./_tmp-db - ❯❯ ${SpineBIN} -v --sqlite-update --sqlite-db-filename=${SpineSQLdb} --sqlite-db-path=./_tmp-db ./markup/pod/* + ❯❯ ${SpineBIN} -v --sqlite-update --sqlite-db-filename=${SpineSQLdb} --sqlite-db-path=./_tmp-db ${SpinePOD}/* - ❯❯ $SpineBIN --source --pod --curate --text --latex --epub --html --manifest --html-link-search --html-link-pdf --html-link-text --html-link-curate --html-link-markup --html-link-source --html-link-pod --html-link-metadata --cgi-sqlite-search-filename="$SpineCGIform" --cgi-url-action="$SpineSearchActionRemote" --sqlite-db-path="$SpineDBpath" --sqlite-db-filename="$SpineSQLdb" --www-url-doc-root=$SpineURLdocRoot --set-papersize="a4,letter" --output=$SpineOUT $SpinePOD/* + ❯❯ ${SpineBIN} --source --pod --curate --text --latex --epub --html --manifest --html-link-search --html-link-pdf --html-link-text --html-link-curate --html-link-markup --html-link-source --html-link-pod --html-link-metadata --cgi-sqlite-search-filename="${SpineCGIform}" --cgi-url-action="${SpineSearchActionRemote}" --sqlite-db-path="${SpineDBpath}" --sqlite-db-filename="${SpineSQLdb}" --www-url-doc-root=${SpineURLdocRoot} --set-papersize="a4,letter" --output=${SpineOUT} ${SpinePOD}/* ' echo "• ❯❯ ${SpineBIN} -v --source --pod --epub --html --html-link-curate --html-link-markup --curate --output=${SpineOUT} ${SpinePOD}/* @@ -136,6 +138,7 @@ echo "• ** .envrc-git-init #+HEADER: :tangle ../.envrc-git-init +#+HEADER: :shebang "# -*- mode: sh -*-" #+HEADER: :noweb yes #+BEGIN_SRC shell if [[ ! -d ./.git ]]; then @@ -162,6 +165,7 @@ SpineProjVer=`rg "Version\((\d+), (\d+), (\d+)\)" views/version.txt | sed -E 's/ - bespoke modify appropriately and generate if needed #+HEADER: :tangle ../.envrc-local_ +#+HEADER: :shebang "# -*- mode: sh -*-" #+HEADER: :noweb yes #+BEGIN_SRC shell export SpineVER=$(git describe --long --tags | sed 's/^[ a-z_-]\+\([0-9.]\+\)/\1/;s/\([^-]*-g\)/r\1/;s/-/./g') @@ -174,8 +178,9 @@ export SpineBIN=./result/bin/spine #export SpineBIN=./bin/spine-dmd # ❯❯ location of source files: export SpineDOC=../sisudoc-spine-samples +#export SpineDOC=./sisudoc-spine-samples # ❯❯ location of source files pod: -export SpinePOD=${SpineDOC}/markup/pod +export SpinePOD=${SpineDOC}/markup/pod-samples/pod # ❯❯ sisudoc-spine output processing path: export SpineOUT=./OUTPUT_TEST_sisudocSpine # ❯❯ sisudoc-spine output processing path (web server e.g.): @@ -254,8 +259,6 @@ export SpineDBpath=/var/www/sqlite <<./sisudoc_spine_version_info_and_doc_header_including_copyright_and_license.org:spine_project_version()>> #+END_SRC -** year - #+NAME: year #+HEADER: :noweb yes #+BEGIN_SRC emacs-lisp diff --git a/org/config_nix.org b/org/config_nix.org index d7e0e92..167a406 100644 --- a/org/config_nix.org +++ b/org/config_nix.org @@ -57,7 +57,8 @@ inherit system; }; preBuild = '' - export HOME=$(pwd) + export HOME=$TMPDIR + #export HOME=$(pwd) ''; installPhase = '' runHook preInstall @@ -68,6 +69,7 @@ postInstall = '' echo "❯❯ ./result/bin/spine -v --source --pod --text --epub --html --html-link-pdf --html-link-curate --html-link-markup --curate --output=./OUTPUT_TEST_sisudocSpine ../sisu-spine-samples/markup/pod/*"; echo `ls -la $out/bin/spine` + echo "❯❯ spine-v${version} (rev: ${self.shortRev or "unknown"})" $out/bin/spine -v ''; in { @@ -232,13 +234,15 @@ pkgs-ovl = pkgsForSystem system; pkgs-nix = nixpkgsFor.${system}; shellHook = '' - export Date=`date "+%Y%m%d"` + #export Date=`date "+%Y%m%d"` ## set local values in .envrc-local (or here if you must) echo '❯❯ nix build'; - SpineProjVer=`rg "Version\((\d+), (\d+), (\d+)\)" views/version.txt | sed -E 's/.*([0-9]+), ([0-9]+), ([0-9]+).*/spine-v\1.\2.\3/'` && \ - SpineGitVer=`git describe | sed "s/^[a-z_-]\+\([0-9.]\+\)/\1/" | sed "s/\([^-]*-g\)/r\1/" | sed "s/-/./g"` && \ - SpineGitBranch=`git branch --show-current` && \ - echo "❯❯ $SpineProjVer - ($SpineGitBranch: $SpineGitVer)" + ## ImPure Nix environment + SpineGitVer=`git describe | sed "s/^[a-z_-]\+\([0-9.]\+\)/\1/" | sed "s/\([^-]*-g\)/r\1/" | sed "s/-/./g"` && \ + SpineGitBranch=`git branch --show-current` && \ + echo "❯❯ spine-v${version} - ($SpineGitBranch: $SpineGitVer)" + ## Pure Nix environment - version info from flake inputs + #echo "❯❯ spine-v${version} (rev: ${self.shortRev or "unknown"})" echo '❯❯ $SpineBIN -v --source --pod --text --epub --html --html-link-pdf --html-link-curate --html-link-markup --curate --output=$SpineOUT $SpinePOD/*'; echo "❯❯ $SpineBIN -v --source --pod --text --epub --html --html-link-pdf --html-link-curate --html-link-markup --curate --output=$SpineOUT $SpinePOD/*"; echo '❯❯ nix flake update && nix flake check && nix flake show'; @@ -256,7 +260,7 @@ dtools gnumake sqlite - gnused + gnugrep gnused ripgrep ]; inherit shellHook; @@ -271,7 +275,7 @@ dtools gnumake sqlite - gnused + gnugrep gnused ripgrep ]; inherit shellHook; @@ -286,7 +290,7 @@ dtools gnumake sqlite - gnused + gnugrep gnused ripgrep ]; inherit shellHook; @@ -301,7 +305,7 @@ dtools gnumake sqlite - gnused + gnugrep gnused ripgrep ]; inherit shellHook; @@ -345,7 +349,7 @@ calibre #(suite includes: ebook-viewer) koreader foliate - gnused + gnugrep gnused ripgrep ]; inherit shellHook; @@ -368,7 +372,7 @@ w3m # ❯❯ light graphical #dillo - gnused + gnugrep gnused ripgrep ]; inherit shellHook; @@ -387,7 +391,7 @@ source-serif-pro source-code-pro texlive.combined.scheme-full - gnused + gnugrep gnused ripgrep ]; inherit shellHook; @@ -403,7 +407,7 @@ dtools gnumake sqlite - gnused + gnugrep gnused ripgrep ]; inherit shellHook; @@ -420,7 +424,7 @@ gnumake sqlite perl538Packages.Po4a - gnused + gnugrep gnused ripgrep ]; inherit shellHook; diff --git a/org/default_regex.org b/org/default_regex.org index 1470c76..1c0ca2f 100644 --- a/org/default_regex.org +++ b/org/default_regex.org @@ -634,6 +634,7 @@ static inline_link_hash = ctRegex!(`┥(?P<text>.+?)┝ static inline_link_seg_and_hash = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>(?P<seg>[^/#├]*)#(?P<hash>.+?))├`, "mg"); static inline_link_clean = ctRegex!(`┤(?:.+?)├|[┥┝]`, "mg"); static inline_link_toc_to_backmatter = ctRegex!(`┤#(?P<link>endnotes|bibliography|bookindex|glossary|blurb)├`, "mg"); +static find_bookindex_ocn_link_and_comma = ctRegex!(`[, ]*┥.+?┝┤#?\S+?├`, "mg"); static url = ctRegex!(`https?://`, "mg"); static uri = ctRegex!(`(?:https?|git)://`, "mg"); static uri_identify_components = ctRegex!(`(?P<type>(?:https?|git)://)(?P<path>\S+?/)(?P<file>[^/]+)$`, "mg"); diff --git a/org/out_text.org b/org/out_text.org index 7a990a1..02d6294 100644 --- a/org/out_text.org +++ b/org/out_text.org @@ -212,8 +212,7 @@ template munge() { string newlines = "\n\n"; template special_characters_and_font_face() { string code(string _txt){ - _txt = _txt - .replaceAll(rgx.nbsp_char, " "); + _txt = _txt.replaceAll(rgx.nbsp_char, " "); return _txt; } string general(string _txt) { @@ -235,21 +234,16 @@ template munge() { return _txt; } string links_and_images(string _txt){ - if (_txt.matchFirst(rgx.inline_link)) { + if (_txt.match(rgx.inline_link)) { foreach (m; _txt.matchAll(rgx.inline_link)) { - if (m.captures[3] == "0") { - _txt = _txt - .replaceFirst(rgx.inline_link, (m.captures[1])); - } else { - _txt = _txt - .replaceFirst(rgx.inline_link, (m.captures[1] ~ " ≫" ~ m.captures[3])); - } + _txt = (m.captures[3] == "0") + ? _txt.replaceFirst(rgx.inline_link, (m.captures[1])) + : _txt.replaceFirst(rgx.inline_link, (m.captures[1] ~ " ≫" ~ m.captures[3])); } } if (_txt.matchFirst(rgx.inline_image)) { foreach (m; _txt.matchAll(rgx.inline_image)) { - _txt = _txt - .replaceFirst(rgx.inline_image, (m.captures[3])); + _txt = _txt.replaceFirst(rgx.inline_image, (m.captures[3])); } } return _txt; @@ -260,28 +254,22 @@ template munge() { string _notes; string _ocn; string general_munge; - if (obj.metainfo.ocn == 0 || doc_matters.opt.action.ocn_off) { - _ocn = ""; - } else { - _ocn = "「" ~ obj.metainfo.ocn.to!string ~ "」" ~ newline; - } + _ocn = (obj.metainfo.ocn == 0 || doc_matters.opt.action.ocn_off) + ? "" : "「" ~ obj.metainfo.ocn.to!string ~ "」" ~ newline; if (_txt.matchFirst(rgx.inline_notes_al_gen)) { foreach (m; _txt.matchAll(rgx.inline_notes_al_regular_number_note)) { - _notes ~= newlines ~ m["num"] ~ ". " ~ m["note"]; + _notes ~= newlines ~ m["num"] ~ ". " + ~ special_characters_and_font_face!().general(m["note"].replaceAll(rgx.inline_link, ("$1"))); } } _txt = _txt.replaceAll(rgx.inline_notes_al_regular_number_note, "[$1]"); - if (obj.metainfo.is_a == "code") { - _txt = special_characters_and_font_face!().code(_txt); - } else { - _txt = special_characters_and_font_face!().general(_txt); - } + _txt = (obj.metainfo.is_a == "code") + ? special_characters_and_font_face!().code(_txt) + : special_characters_and_font_face!().general(_txt); _txt = special_characters_and_font_face!().links_and_images(_txt); - if (obj.metainfo.is_a == "heading") { - general_munge = newline ~ _txt ~ _notes ~ newline ~ _ocn ~ newline; - } else { - general_munge = _txt ~ _notes ~ newline ~ _ocn ~ newline; - } + general_munge = (obj.metainfo.is_a == "heading") + ? newline ~ _txt ~ _notes ~ newline ~ _ocn ~ newline + : _txt ~ _notes ~ newline ~ _ocn ~ newline; return general_munge; } string toc(O,M)(O obj, M doc_matters) { @@ -310,7 +298,9 @@ template munge() { default: break; } - _txt = _txt.replaceAll(rgx.inline_link, (_spaces ~ "$1 ≫ $3")); + _txt = (doc_matters.opt.action.ocn_off) + ? _txt.replaceAll(rgx.inline_link, (_spaces ~ "$1")) + : _txt.replaceAll(rgx.inline_link, (_spaces ~ "$1 ≫ $3")); return _txt ~ newline; } string heading(O,M)(O obj, M doc_matters) { @@ -454,19 +444,24 @@ template munge() { string _ocn; _ocn = "「" ~ obj.metainfo.ocn.to!string ~ "」"; string _txt = obj.text; + string _parent_ocn; _txt = _txt - .replaceAll(rgx.inline_link, ("$1")) // consider - .replaceFirst(rgx.inline_superscript, ("$1")); - _txt = special_characters_and_font_face!().general(_txt) ~ " ≫" ~ obj.metainfo.parent_ocn.to!string; + .replaceAll(rgx.inline_link, ("$1")) // consider + .replaceFirst(rgx.inline_superscript, ("$1")); + _parent_ocn = (obj.metainfo.parent_ocn == 0 || doc_matters.opt.action.ocn_off) + ? "" : " ≫" ~ obj.metainfo.parent_ocn.to!string; + _txt = special_characters_and_font_face!().general(_txt) ~ _parent_ocn; return _txt ~ newlines; } string bookindex(O,M)(O obj, M doc_matters) { // puts(obj.metainfo.is_a); // return obj.metainfo.is_a; string _txt = obj.text; - _txt = _txt - .replaceAll(rgx.inline_link, ("≫$1")) - .replaceAll(regex("\\s*\\\\"), ""); + _txt = (doc_matters.opt.action.ocn_off) + ? _txt.replaceAll(rgx.find_bookindex_ocn_link_and_comma, "") + .replaceAll(regex("\\s*\\\\"), "") + : _txt.replaceAll(rgx.inline_link, ("≫$1")) + .replaceAll(regex("\\s*\\\\"), ""); _txt = special_characters_and_font_face!().general(_txt); return _txt ~ newlines; } diff --git a/org/spine.org b/org/spine.org index 8f0af14..9971dc2 100644 --- a/org/spine.org +++ b/org/spine.org @@ -321,6 +321,7 @@ bool[string] opts = [ "light" : false, "manifest" : false, "hide-ocn" : false, + "no-ocn" : false, "ocn-off" : false, "odf" : false, "odt" : false, @@ -444,6 +445,7 @@ auto helpInfo = getopt(args, "latex-header-sty", "latex document header sty files", &opts["latex-header-sty"], "light", "default light theme", &opts["light"], "manifest", "process manifest output", &opts["manifest"], + "no-ocn", "object cite numbers", &opts["no-ocn"], "ocn-off", "object cite numbers", &opts["ocn-off"], "odf", "open document format text (--odt)", &opts["odf"], "odt", "open document format text", &opts["odt"], @@ -675,7 +677,7 @@ struct OptActions { return opts["hide-ocn"]; } @trusted bool ocn_off() { - return opts["ocn-off"]; + return ((opts["ocn-off"]) || (opts["no-ocn"])) ? true : false; } @trusted bool pod() { return opts["pod"]; diff --git a/src/sisudoc/io_out/rgx.d b/src/sisudoc/io_out/rgx.d index 1327854..f54deda 100644 --- a/src/sisudoc/io_out/rgx.d +++ b/src/sisudoc/io_out/rgx.d @@ -110,6 +110,7 @@ static template spineRgxOut() { static inline_link_seg_and_hash = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>(?P<seg>[^/#├]*)#(?P<hash>.+?))├`, "mg"); static inline_link_clean = ctRegex!(`┤(?:.+?)├|[┥┝]`, "mg"); static inline_link_toc_to_backmatter = ctRegex!(`┤#(?P<link>endnotes|bibliography|bookindex|glossary|blurb)├`, "mg"); + static find_bookindex_ocn_link_and_comma = ctRegex!(`[, ]*┥.+?┝┤#?\S+?├`, "mg"); static url = ctRegex!(`https?://`, "mg"); static uri = ctRegex!(`(?:https?|git)://`, "mg"); static uri_identify_components = ctRegex!(`(?P<type>(?:https?|git)://)(?P<path>\S+?/)(?P<file>[^/]+)$`, "mg"); diff --git a/src/sisudoc/io_out/text.d b/src/sisudoc/io_out/text.d index ce37310..9401bae 100644 --- a/src/sisudoc/io_out/text.d +++ b/src/sisudoc/io_out/text.d @@ -66,8 +66,7 @@ template outputText() { string newlines = "\n\n"; template special_characters_and_font_face() { string code(string _txt){ - _txt = _txt - .replaceAll(rgx.nbsp_char, " "); + _txt = _txt.replaceAll(rgx.nbsp_char, " "); return _txt; } string general(string _txt) { @@ -89,21 +88,16 @@ template outputText() { return _txt; } string links_and_images(string _txt){ - if (_txt.matchFirst(rgx.inline_link)) { + if (_txt.match(rgx.inline_link)) { foreach (m; _txt.matchAll(rgx.inline_link)) { - if (m.captures[3] == "0") { - _txt = _txt - .replaceFirst(rgx.inline_link, (m.captures[1])); - } else { - _txt = _txt - .replaceFirst(rgx.inline_link, (m.captures[1] ~ " ≫" ~ m.captures[3])); - } + _txt = (m.captures[3] == "0") + ? _txt.replaceFirst(rgx.inline_link, (m.captures[1])) + : _txt.replaceFirst(rgx.inline_link, (m.captures[1] ~ " ≫" ~ m.captures[3])); } } if (_txt.matchFirst(rgx.inline_image)) { foreach (m; _txt.matchAll(rgx.inline_image)) { - _txt = _txt - .replaceFirst(rgx.inline_image, (m.captures[3])); + _txt = _txt.replaceFirst(rgx.inline_image, (m.captures[3])); } } return _txt; @@ -114,28 +108,22 @@ template outputText() { string _notes; string _ocn; string general_munge; - if (obj.metainfo.ocn == 0 || doc_matters.opt.action.ocn_off) { - _ocn = ""; - } else { - _ocn = "「" ~ obj.metainfo.ocn.to!string ~ "」" ~ newline; - } + _ocn = (obj.metainfo.ocn == 0 || doc_matters.opt.action.ocn_off) + ? "" : "「" ~ obj.metainfo.ocn.to!string ~ "」" ~ newline; if (_txt.matchFirst(rgx.inline_notes_al_gen)) { foreach (m; _txt.matchAll(rgx.inline_notes_al_regular_number_note)) { - _notes ~= newlines ~ m["num"] ~ ". " ~ m["note"]; + _notes ~= newlines ~ m["num"] ~ ". " + ~ special_characters_and_font_face!().general(m["note"].replaceAll(rgx.inline_link, ("$1"))); } } _txt = _txt.replaceAll(rgx.inline_notes_al_regular_number_note, "[$1]"); - if (obj.metainfo.is_a == "code") { - _txt = special_characters_and_font_face!().code(_txt); - } else { - _txt = special_characters_and_font_face!().general(_txt); - } + _txt = (obj.metainfo.is_a == "code") + ? special_characters_and_font_face!().code(_txt) + : special_characters_and_font_face!().general(_txt); _txt = special_characters_and_font_face!().links_and_images(_txt); - if (obj.metainfo.is_a == "heading") { - general_munge = newline ~ _txt ~ _notes ~ newline ~ _ocn ~ newline; - } else { - general_munge = _txt ~ _notes ~ newline ~ _ocn ~ newline; - } + general_munge = (obj.metainfo.is_a == "heading") + ? newline ~ _txt ~ _notes ~ newline ~ _ocn ~ newline + : _txt ~ _notes ~ newline ~ _ocn ~ newline; return general_munge; } string toc(O,M)(O obj, M doc_matters) { @@ -164,7 +152,9 @@ template outputText() { default: break; } - _txt = _txt.replaceAll(rgx.inline_link, (_spaces ~ "$1 ≫ $3")); + _txt = (doc_matters.opt.action.ocn_off) + ? _txt.replaceAll(rgx.inline_link, (_spaces ~ "$1")) + : _txt.replaceAll(rgx.inline_link, (_spaces ~ "$1 ≫ $3")); return _txt ~ newline; } string heading(O,M)(O obj, M doc_matters) { @@ -308,19 +298,24 @@ template outputText() { string _ocn; _ocn = "「" ~ obj.metainfo.ocn.to!string ~ "」"; string _txt = obj.text; + string _parent_ocn; _txt = _txt - .replaceAll(rgx.inline_link, ("$1")) // consider - .replaceFirst(rgx.inline_superscript, ("$1")); - _txt = special_characters_and_font_face!().general(_txt) ~ " ≫" ~ obj.metainfo.parent_ocn.to!string; + .replaceAll(rgx.inline_link, ("$1")) // consider + .replaceFirst(rgx.inline_superscript, ("$1")); + _parent_ocn = (obj.metainfo.parent_ocn == 0 || doc_matters.opt.action.ocn_off) + ? "" : " ≫" ~ obj.metainfo.parent_ocn.to!string; + _txt = special_characters_and_font_face!().general(_txt) ~ _parent_ocn; return _txt ~ newlines; } string bookindex(O,M)(O obj, M doc_matters) { // puts(obj.metainfo.is_a); // return obj.metainfo.is_a; string _txt = obj.text; - _txt = _txt - .replaceAll(rgx.inline_link, ("≫$1")) - .replaceAll(regex("\\s*\\\\"), ""); + _txt = (doc_matters.opt.action.ocn_off) + ? _txt.replaceAll(rgx.find_bookindex_ocn_link_and_comma, "") + .replaceAll(regex("\\s*\\\\"), "") + : _txt.replaceAll(rgx.inline_link, ("≫$1")) + .replaceAll(regex("\\s*\\\\"), ""); _txt = special_characters_and_font_face!().general(_txt); return _txt ~ newlines; } diff --git a/src/sisudoc/meta/rgx.d b/src/sisudoc/meta/rgx.d index da48658..86ca40c 100644 --- a/src/sisudoc/meta/rgx.d +++ b/src/sisudoc/meta/rgx.d @@ -251,6 +251,7 @@ static template spineRgxIn() { static inline_link_seg_and_hash = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>(?P<seg>[^/#├]*)#(?P<hash>.+?))├`, "mg"); static inline_link_clean = ctRegex!(`┤(?:.+?)├|[┥┝]`, "mg"); static inline_link_toc_to_backmatter = ctRegex!(`┤#(?P<link>endnotes|bibliography|bookindex|glossary|blurb)├`, "mg"); + static find_bookindex_ocn_link_and_comma = ctRegex!(`[, ]*┥.+?┝┤#?\S+?├`, "mg"); static url = ctRegex!(`https?://`, "mg"); static uri = ctRegex!(`(?:https?|git)://`, "mg"); static uri_identify_components = ctRegex!(`(?P<type>(?:https?|git)://)(?P<path>\S+?/)(?P<file>[^/]+)$`, "mg"); diff --git a/src/sisudoc/spine.d b/src/sisudoc/spine.d index 82138f7..f53fc09 100755 --- a/src/sisudoc/spine.d +++ b/src/sisudoc/spine.d @@ -154,6 +154,7 @@ string program_name = "spine"; "light" : false, "manifest" : false, "hide-ocn" : false, + "no-ocn" : false, "ocn-off" : false, "odf" : false, "odt" : false, @@ -263,6 +264,7 @@ string program_name = "spine"; "latex-header-sty", "latex document header sty files", &opts["latex-header-sty"], "light", "default light theme", &opts["light"], "manifest", "process manifest output", &opts["manifest"], + "no-ocn", "object cite numbers", &opts["no-ocn"], "ocn-off", "object cite numbers", &opts["ocn-off"], "odf", "open document format text (--odt)", &opts["odf"], "odt", "open document format text", &opts["odt"], @@ -487,7 +489,7 @@ string program_name = "spine"; return opts["hide-ocn"]; } @trusted bool ocn_off() { - return opts["ocn-off"]; + return ((opts["ocn-off"]) || (opts["no-ocn"])) ? true : false; } @trusted bool pod() { return opts["pod"]; |
