texlive[69164] Master/texmf-dist: q-and-a (18dec23)

commits+karl at tug.org commits+karl at tug.org
Mon Dec 18 21:57:46 CET 2023


Revision: 69164
          https://tug.org/svn/texlive?view=revision&revision=69164
Author:   karl
Date:     2023-12-18 21:57:45 +0100 (Mon, 18 Dec 2023)
Log Message:
-----------
q-and-a (18dec23)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/q-and-a/demo/theme-ChatGPT/Q-and-A-demo-ChatGPT-dark.pdf
    trunk/Master/texmf-dist/doc/latex/q-and-a/demo/theme-ChatGPT/Q-and-A-demo-ChatGPT-light.pdf
    trunk/Master/texmf-dist/doc/latex/q-and-a/doc/Q-and-A-doc.pdf
    trunk/Master/texmf-dist/doc/latex/q-and-a/doc/Q-and-A-doc.tex
    trunk/Master/texmf-dist/tex/latex/q-and-a/Q-and-A.cls

Modified: trunk/Master/texmf-dist/doc/latex/q-and-a/demo/theme-ChatGPT/Q-and-A-demo-ChatGPT-dark.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/q-and-a/demo/theme-ChatGPT/Q-and-A-demo-ChatGPT-light.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/q-and-a/doc/Q-and-A-doc.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/q-and-a/doc/Q-and-A-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/q-and-a/doc/Q-and-A-doc.tex	2023-12-18 20:57:13 UTC (rev 69163)
+++ trunk/Master/texmf-dist/doc/latex/q-and-a/doc/Q-and-A-doc.tex	2023-12-18 20:57:45 UTC (rev 69164)
@@ -5,7 +5,7 @@
   scroll,
 ]{Q-and-A}
 
-\def\PackageVersion{2023/11/21}
+\def\PackageVersion{2023/12/19}
 \def\PackageSubVersion{}
 
 \newcommand{\QApackage}{{\normalfont\textsf{Q-and-A}}}
@@ -212,7 +212,7 @@
     \item Likewise, a `section`/`subsection`/`subsubsection` should be placed in a separate paragraph.
     \item Input or inclusion of files should also be operated in a separate paragraph.
     \item For emphasizing and bolding the text, it would be necessary to separate the asterisks with~`\{\}` in some special cases: `\textasterisk\textasterisk like\textasterisk\textasterisk\{\}\textasterisk\textasterisk\textasterisk this\textasterisk\textasterisk\textasterisk\{\}\textasterisk one\textasterisk`.
-    \item Due to the recognition of the syntax, you cannot directly use characters like `\textasterisk` as usual, especially in math mode. You should consider using an alternative macro, such as `\textbackslash ast` for `\textasterisk` in math mode, or define a command version of the character in the preamble, such as `\textbackslash textasterisk` for `\textasterisk`. A list of predefined commands are:
+    \item Due to the recognition of the syntax, you may not be able to directly write characters like `\textasterisk` as usual. You should consider using a command version of the character, such as `\textbackslash textasterisk` for `\textasterisk`. A list of predefined commands are:
     \begin{itemize}
       \item `\textbackslash textasterisk` for `\textasterisk`;
       \item `\textbackslash textbacktick` for `\textbacktick`;
@@ -291,7 +291,8 @@
     \item Currently, the code highlight is done by the package `listings`. Due to its own limitations, the result is still far from satisfactory. Using `minted` instead could improve the situation, but this would require `-shell-escape` and some external tweaking, thus it would still take some effort to make it work with the current document class.
     \item Due to the current implementation, one cannot direct write code (either inline or displayed) within the text (alternative solution has been proposed above).
     \item Due to the current implementation, when displaying the code, one may not be able to write some of the language name like `C\#` directly, but has to write an alternative name such as `csharp`.
-    \item Due to the current implementation, one may not be able to directly write certain characters (such as `\textasterisk`) in the text, this might be especially inconvenient in math mode (temporary alternative solution has been proposed above).
+    % \item Due to the current implementation, one may not be able to directly write certain characters (such as `\textasterisk`) in the text, this might be especially inconvenient in math mode (temporary alternative solution has been proposed above).
+    %% 2023-12-19, solved with some internal improvements
     \item Due to the current implementation, the method for inputting and including subfiles doesn't really work like `\textbackslash input` and `\textbackslash include`. In particular, the current type of conversation would be reset, this might cause some confusion in certain cases.
     % \item The code block containing long piece of code usually won't properly break across the page (which is essentially why this documentation and the demo documents enabled the `scroll` mode).
     %% 2023-11-05, solved with the new option "answer outside the box".

Modified: trunk/Master/texmf-dist/tex/latex/q-and-a/Q-and-A.cls
===================================================================
--- trunk/Master/texmf-dist/tex/latex/q-and-a/Q-and-A.cls	2023-12-18 20:57:13 UTC (rev 69163)
+++ trunk/Master/texmf-dist/tex/latex/q-and-a/Q-and-A.cls	2023-12-18 20:57:45 UTC (rev 69164)
@@ -12,7 +12,7 @@
 \NeedsTeXFormat{LaTeX2e}[2023/11/01]
 \ProvidesExplClass
   {Q-and-A}
-  {2023/11/21} {}
+  {2023/12/19} {}
   {Document class for typesetting Q&A conversation}
 
 \keys_define:nn { Q-and-A }
@@ -138,6 +138,7 @@
 
 \str_if_eq:onT { \l__QA_theme_str } { ChatGPT-dark }
   {
+    \definecolor{QA-code-title-back}{RGB}{ 32, 33, 35}
     \definecolor{QA-Q-back}{RGB}{ 52, 53, 65}
     \definecolor{QA-Q-text}{RGB}{236,236,241}
     \definecolor{QA-Q-emph}{RGB}{255,255,255}
@@ -864,7 +865,7 @@
     \colorlet{paper}{QA-N-back}
     \colorlet{main-text}{QA-N-text}
     \colorlet{emph-text}{QA-N-emph}
-    \str_if_in:NnT \l__QA_theme_str { ChatGPT }
+    \str_if_in:NnT \l__QA_theme_str { ChatGPT-classical }
       {
         \colorlet{QA-code-title-back}{QA-A-back}
         \colorlet{QA-code-title-text}{QA-A-text}
@@ -1301,6 +1302,27 @@
 \tl_new:N \l_QA_tmp_tl
 \tl_new:N \g_QA_current_content_tl
 \cs_generate_variant:Nn \regex_split:nnN { nVN }
+% https://tex.stackexchange.com/a/703640
+\cs_new:Nn \QA_regex_replace_case_once_skip_math:nN
+  {
+    \regex_replace_case_once:nN
+      {
+        { \$ (.*?) \$ } { \0 }
+        { \c{\(} (.*?) \c{\)} } { \0 }
+        { \c{\[} (.*?) \c{\]} } { \0 }
+        #1
+      } #2
+  }
+\cs_new:Nn \QA_regex_replace_case_all_skip_math:nN
+  {
+    \regex_replace_case_all:nN
+      {
+        { \$ (.*?) \$ } { \0 }
+        { \c{\(} (.*?) \c{\)} } { \0 }
+        { \c{\[} (.*?) \c{\]} } { \0 }
+        #1
+      } #2
+  }
 \cs_new:Nn \QA_parse_content:N
   {
     \tl_set:Nn \l__QA_current_type_tl { void }
@@ -1393,18 +1415,24 @@
               { \QACaption { ####1 } }
           }
 
-        \regex_replace_all:nnN
-          { \|\| }
-          { \c{QAShowImageCenter} }
-          \l_QA_tmp_tl
-        \regex_replace_all:nnN
-          { \(\( }
-          { \c{QAShowImageLeft} }
-          \l_QA_tmp_tl
-        \regex_replace_all:nnN
-          { \)\) }
-          { \c{QAShowImageRight} }
-          \l_QA_tmp_tl
+        % \regex_replace_all:nnN
+        %   { \|\| }
+        %   { \c{QAShowImageCenter} }
+        %   \l_QA_tmp_tl
+        % \regex_replace_all:nnN
+        %   { \(\( }
+        %   { \c{QAShowImageLeft} }
+        %   \l_QA_tmp_tl
+        % \regex_replace_all:nnN
+        %   { \)\) }
+        %   { \c{QAShowImageRight} }
+        %   \l_QA_tmp_tl
+        \QA_regex_replace_case_all_skip_math:nN
+          {
+            { \|\| } { \c{QAShowImageCenter} }
+            { \(\( } { \c{QAShowImageLeft} }
+            { \)\) } { \c{QAShowImageRight} }
+          } \l_QA_tmp_tl
 
         \bool_set_false:N \l_QA_regex_no_more_match_bool
         \bool_do_until:nn \l_QA_regex_no_more_match_bool
@@ -1495,18 +1523,24 @@
           { \c{QAEnum} \2 {\1} {\3} }
           \l_QA_tmp_tl
 
-        \regex_replace_all:nnN
-          { \*\*\* (.*?) \*\*\* }
-          { \c{QAEmph} { \c{emph} {\1} } }
-          \l_QA_tmp_tl
-        \regex_replace_all:nnN
-          { \*\* (.*?) \*\* }
-          { \c{QAEmph} {\1} }
-          \l_QA_tmp_tl
-        \regex_replace_all:nnN
-          { \* (.*?) \* }
-          { \c{emph} {\1} }
-          \l_QA_tmp_tl
+        % \regex_replace_all:nnN
+        %   { \*\*\* (.*?) \*\*\* }
+        %   { \c{QAEmph} { \c{emph} {\1} } }
+        %   \l_QA_tmp_tl
+        % \regex_replace_all:nnN
+        %   { \*\* (.*?) \*\* }
+        %   { \c{QAEmph} {\1} }
+        %   \l_QA_tmp_tl
+        % \regex_replace_all:nnN
+        %   { \* (.*?) \* }
+        %   { \c{emph} {\1} }
+        %   \l_QA_tmp_tl
+        \QA_regex_replace_case_all_skip_math:nN
+          {
+            { \*\*\* (.*?) \*\*\* } { \c{QAEmph} { \c{emph} { \1 } } }
+            { \*\* (.*?) \*\* } { \c{QAEmph} { \1 } }
+            { \* (.*?) \* } { \c{emph} { \1 } }
+          } \l_QA_tmp_tl
 
         \regex_replace_once:nnN { ❄️ } { } \l_QA_tmp_tl
 



More information about the tex-live-commits mailing list.