From 883cdb7f41c3824597b1d739a8a41a6457b6cf8f Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sat, 11 Sep 2021 18:59:46 -0700 Subject: [PATCH] doc: Fix the rendering of double quotes and semicolons CMake uses quotes and semicolon in its internal list datatype. Previously, all double quotes were converted to single quotes to avoid this problem. Semicolors were interpreted as newlines in ldoc. With this commit, both of them render fine. This was required because a new example uses CSS and XML where those symbols have a specific meanning. --- docs/ldoc.ltp | 9 +++++---- tests/examples/CMakeLists.txt | 8 +++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/docs/ldoc.ltp b/docs/ldoc.ltp index 148ac6d2f..01b260b9f 100644 --- a/docs/ldoc.ltp +++ b/docs/ldoc.ltp @@ -38,7 +38,8 @@ # local use_li = ldoc.use_li # local display_name = ldoc.display_name # local iter = ldoc.modules.iter -# local function M(txt,item) return ldoc.markup(txt,item,ldoc.plain) end +# local function un_cmake(s) return s:gsub(";", ";"):gsub(""", '"') end +# local function M(txt,item) return ldoc.markup(txt and un_cmake(txt) or nil,item,ldoc.plain) end # local nowrap = ldoc.wrap and '' or 'nowrap' # local html_space = function(s) return s:gsub(" ", "%%20") end # local no_underscores = function(s) return s:gsub("_", " ") end @@ -189,7 +190,7 @@

Usage:

# end -- if usage @@ -331,7 +332,7 @@ # end # if kitem.usage then

Usage:

-
$(ldoc.prettify(kitem.usage[1]))
+
$(ldoc.prettify(un_cmake(kitem.usage[1])))
# end # end # if not kind:match("^ldoc_skip") then @@ -450,7 +451,7 @@

Usage:

# end -- if usage diff --git a/tests/examples/CMakeLists.txt b/tests/examples/CMakeLists.txt index 328ad98de..83173cf6f 100644 --- a/tests/examples/CMakeLists.txt +++ b/tests/examples/CMakeLists.txt @@ -85,7 +85,9 @@ function(escape_string variable content escaped_content line_prefix) if(variable MATCHES "--DOC_HIDE_ALL") return() endif() - string(REGEX REPLACE "\n" ";" var_lines "${variable}") + + string(REGEX REPLACE ";" ";" var_lines "${variable}") + string(REGEX REPLACE "\n" ";" var_lines "${var_lines}") set(tmp_output ${content}) set(section OFF) @@ -101,7 +103,7 @@ function(escape_string variable content escaped_content line_prefix) # Pick lines that are not specified to be hidden if((NOT LINE MATCHES "^.*--DOC_[A-Z]+") AND (NOT section)) - set(tmp_output ${tmp_output}\n${DOC_LINE_PREFIX}${line_prefix}${LINE}) + set(tmp_output "${tmp_output}\n${DOC_LINE_PREFIX}${line_prefix}${LINE}") endif() # If we found a start marker previously, look for an end marker. @@ -347,7 +349,7 @@ foreach(file ${test_files}) # variable during the pre-processing. # While at it, replace \" created by CMake by ', # " wont work in . - string(REPLACE "\"" "'" ${TEST_NAME} ${ESCAPED_CODE_EXAMPLE}) + string(REPLACE "\"" """ ${TEST_NAME} ${ESCAPED_CODE_EXAMPLE}) endif() endforeach()