From 3b4a7e19b216d5010dec1d93b063d51d00666b94 Mon Sep 17 00:00:00 2001 From: Matt McCutchen Date: Mon, 7 Sep 2020 20:16:14 -0400 Subject: [PATCH] Import SuperbChemistry version 2.2 Modification time: 2008-10-26 23:54:49 -0400 --- SuperbChemistry-test.odt | Bin 7613 -> 8247 bytes extension/SuperbChemistry/Main.xba | 75 ++++++++++++++++++++++------- 2 files changed, 58 insertions(+), 17 deletions(-) diff --git a/SuperbChemistry-test.odt b/SuperbChemistry-test.odt index 3802718d2565e748aa08cdfb828b1f170734323e..9740bbcee3d638ece2330fbfff69a246e690c881 100644 GIT binary patch delta 5325 zcmZ8lby$>5v|m7Kl~zhxkaFpk5Rh6@Bo&ZumhO0^L_l&CB&0iJX{1&_LQ)A4a2Js7 z?$|4zdcW`9^FGhai8=Gkd;a*%?@Y`6`Uk{XsyNqfg0AG8{;7BZvC6fp8P0^o1c%Vx zxN#LE`1So0gg^c#n6N7FcahL<#Q;m>PlO3xg+>0q`tlzgeu*Xid*yv>IzWE_HYY;b zdc=7RtI0NDIEvMo?0zNHQ{Erfl+$xGqD|}~>n5~wpxT$>hu_>Yvxe$4hnej-cO{}Y z=O0{WMW&oAM#!Ho&hc2FUl6GHO7C`{^S2TtXE_J-?_kCYIU9FnVv!$a``FZb_!d-B z5{$CLmcXqH%1dsx-bz87y8v@{Vy{`OAWH-n&2Gs2n^8n01MO2Ug%T-uO3|5u8kYMD zTxFF?RX($@iRWp<#UG#Qo5h4@iF79a(Dh-bdE)lcPtQ~VXI*1aCax_ZCAg!QK=T!$=3sjC-w95Tt3g$_x4;cM%P)~Yx66WvZ2=? z>8P6J0?DQ3f)d-kw&JU2kWJ&MV8 z#>Wz*RSHbtbuXeMyHa3vnsIaKbE@SrjoMHs*+72#huHq?eBo2u<+#!UI~<-+KQqDs z3W%$m7L@#Mw`kq*n$^&tC%Mw)E9+=&Kjij}CG;y2Ne&v0WAM92b&Mxlu5AkkoTKm0 z&A}hV2XytBRYTFC?p|X^gvg)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{-s58W#rk*n$NzH+@_QP@g3~k7JpZNipG@HP z<8l8-$%POEvNv}%=Jm9{%^ki^QU3?DqHL!C diff --git a/extension/SuperbChemistry/Main.xba b/extension/SuperbChemistry/Main.xba index 3b0640e..530cf8d 100644 --- a/extension/SuperbChemistry/Main.xba +++ b/extension/SuperbChemistry/Main.xba @@ -1,12 +1,15 @@ -' Matt McCutchen's SuperbChemistry for OpenOffice, version 2.1 +' SuperbChemistry version 2.2 +' http://mattmccutchen.net/schem/ +' Written and maintained by Matt McCutchen <matt@mattmccutchen.net> ' -' Applies superscript and subscript formatting to chemical formulas in text. +' Applies superscript and subscript formatting to chemical formulas in +' OpenOffice.org Writer documents. ' ' Rules: ' - Quantities [0-9]+ and charges [0-9]*[-+−] are recognized after an element -' symbol [A-Z][a-z]? or a closing delimiter [])}] . Hyphens are converted +' symbol [A-Z][a-z]? or a closing delimiter [\])}] . Hyphens are converted ' into real minus signs. ' - A charge sign [-+−] is ignored if it is followed by a letter, digit, ' opening delimiter, or [<>] . (Charges should appear only at the end of a @@ -14,10 +17,12 @@ ' - When digits followed by a charge sign are recognized, the last digit ' becomes part of the charge and the remaining digits become the quantity. ' (Charges rarely have absolute value more than 9.) -' - Exception: If a single digit follows O or a closing delimiter, that digit -' is always the quantity. (Handle NO3- and Fe(OH)2+. I think oxygen is the -' only element that frequently has a quantity as part of a +/-1 ion. A group -' is rarely parenthesized unless it has a quantity.) +' - In cases like X2-, we have to guess whether the digit is an atom/group +' quantity or a charge amount. We guess atom/group quantity if X is H (NH4+), +' O (NO3-), a halogen (SbF6-, AlCl4-, etc.), or a closing parenthesis +' (Fe(OH)2+; the group likely would not have been parenthesized unless it had +' a quantity). Otherwise we guess charge amount (Fe3+). This heuristic +' should be right most of the time. ' ' Examples: ' C12345 ==> C_{12345} @@ -26,18 +31,51 @@ ' Fe3+ ==> Fe^{3+} ' SO42- ==> SO_4^{2-} ' C1232+ ==> C_{123}^{2+} -' N2- ==> N^{2-} +' N3- ==> N^{3-} +' N|_3^- not recognized (| represents "no-width no break") +' NH4+ ==> NH_4^+ ' NO3- ==> NO_3^- -' Fe(OH)2- ==> Fe(OH)_2^- +' AlCl4- => AlCl_4^- +' Fe(OH)2+ ==> Fe(OH)_2^+ ' O12 ==> O_{12} -' y4- ==> y4- -' x2 ==> x2 -' Foo2 ==> Foo2 -' TI-89 ==> TI-89 +' y4- not recognized +' x2 not recognized +' Foo2 not recognized +' TI-89 not recognized +' +' To format the current document, run the FormatDocument macro: go to Tools -> +' Macros -> Run Macro... -> My Macros -> SuperbChemistry -> Main -> +' FormatDocument -> Run. I realize that this is ugly. I tried to make the +' package install a menu item to format the document, but the resulting package +' caused OpenOffice.org to crash regularly (I didn't investigate why), so I +' abandoned that idea. Note that you can add a menu item as a user +' customization (Tools -> Customize), and I recommend it if you plan to use +' SuperbChemistry frequently. +' +' FormatDocument uses a sequence of regular expression find-and-replace +' operations since that was easy to implement and makes the rules easy to +' change. The operations appear in the undo history, so you can undo a +' formatting run by undoing the block of "Replace" entries at the top of the +' history. +' +' I would like to support formatting a selection, but the OpenOffice.org API +' does not appear to support replace-all within a selection. I could find +' within the selection and implement the replacing myself, but that is more +' work than I want to do. +' +' If SuperbChemistry makes a mistake (e.g., recognizes a "formula" that isn't +' or formats a formula incorrectly), you can correct the formatting yourself +' and prevent future runs of the macro from recognizing the offending text by +' inserting a "No-width no break" character in the middle of it. This character +' is available in the "Insert -> Formatting Mark" menu when "Tools -> Options -> +' Language Settings -> Languages -> Enhanced language support -> +' Enabled for complex text layout (CTL)" is enabled. + +' ============================================================================== ' Regular expression replace in the document, ' creating superscripts if superb > 0 or subscripts if superb < 0. -' Used by SuperbChemistry. +' Used by FormatDocument. sub SuperbReplace(doc as object, searchStr as string, replaceStr as string, superb as integer) dim rd as object @@ -70,7 +108,9 @@ sub FormatDocument ' Idiom: Match something and tag it on the left or right with @x@ ' for further processing. If the replacement text could use -' backreferences, this would be easier. +' backreferences, this would be easier. (I think backreferences were added +' since I originally wrote this code, but I see no need to rewrite it to take +' advantage of them. - Matt 2008-10-26) ' Tag candidate charges following symbols or ), but not in compound words, etc. ' Acceptable next character. (Has to be before end of line to avoid matching @g@ tag itself.) @@ -80,8 +120,9 @@ SuperbReplace(ThisComponent, ".@G@", "@g@&", 0) ' End of line. SuperbReplace(ThisComponent, "([A-Z][a-z]?|[\])}])[0-9]*[-+−]$", "&@g@", 0) -' O and )]} grab a single digit as quantity. -SuperbReplace(ThisComponent, "[\])}O][0-9]", "&@n@", 0) +' Some groups grab a single following digit as a quantity rather than a charge amount. +' See detailed rationale above. +SuperbReplace(ThisComponent, "(H|O|F|Cl|Br|I|\))[0-9]", "&@n@", 0) ' Real minus signs in charges. SuperbReplace(ThisComponent, "-@g@", "−@g@", 0) -- 2.34.1