Import SuperbChemistry version 2.1
authorMatt McCutchen <matt@mattmccutchen.net>
Tue, 8 Sep 2020 00:16:14 +0000 (20:16 -0400)
committerMatt McCutchen <matt@mattmccutchen.net>
Tue, 8 Sep 2020 00:16:14 +0000 (20:16 -0400)
Modification time: 2007-02-05 20:21:05 -0500

SuperbChemistry-test.odt
extension/SuperbChemistry/Main.xba

index a1cf54a..3802718 100644 (file)
Binary files a/SuperbChemistry-test.odt and b/SuperbChemistry-test.odt differ
index 33ccbd1..3b0640e 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
-<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Main" script:language="StarBasic">&apos; Matt McCutchen&apos;s SuperbChemistry for OpenOffice, version 2
+<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Main" script:language="StarBasic">&apos; Matt McCutchen&apos;s SuperbChemistry for OpenOffice, version 2.1
 &apos;
 &apos; Applies superscript and subscript formatting to chemical formulas in text.
 &apos;
@@ -72,12 +72,13 @@ sub FormatDocument
 &apos; for further processing.  If the replacement text could use
 &apos; backreferences, this would be easier.
 
-&apos; Tag candidate quantity/charges following symbols or ).
-SuperbReplace(ThisComponent, &quot;([A-Z][a-z]?|[\])}])[0-9]*[-+−]&quot;, &quot;&amp;@g@&quot;, 0)
-
-&apos; Disqualify + and - in compound words, etc.
-SuperbReplace(ThisComponent, &quot;@g@[[({A-Za-z0-9&lt;&gt;]&quot;, &quot;@G@&amp;&quot;, 0)
-SuperbReplace(ThisComponent, &quot;@G@@g@&quot;, &quot;&quot;, 0)
+&apos; Tag candidate charges following symbols or ), but not in compound words, etc.
+&apos; Acceptable next character.  (Has to be before end of line to avoid matching @g@ tag itself.)
+SuperbReplace(ThisComponent, &quot;([A-Z][a-z]?|[\])}])[0-9]*[-+−][^[({A-Za-z0-9&lt;&gt;]&quot;, &quot;&amp;@G@&quot;, 0)
+&apos; Retag in front.
+SuperbReplace(ThisComponent, &quot;.@G@&quot;, &quot;@g@&amp;&quot;, 0)
+&apos; End of line.
+SuperbReplace(ThisComponent, &quot;([A-Z][a-z]?|[\])}])[0-9]*[-+−]$&quot;, &quot;&amp;@g@&quot;, 0)
 
 &apos; O and )]} grab a single digit as quantity.
 SuperbReplace(ThisComponent, &quot;[\])}O][0-9]&quot;, &quot;&amp;@n@&quot;, 0)