mirror of
https://github.com/LCPQ/QUESTDB_website.git
synced 2024-08-25 13:41:50 +02:00
Merge branch 'master' into QUEST5
This commit is contained in:
commit
67e789de1b
@ -138,4 +138,20 @@ def tabularToData(table,commands=None):
|
||||
table=np.array(lnewtable,TexNode)
|
||||
return table
|
||||
else:
|
||||
raise ValueError("Only tabular LaTeX environment is supported")
|
||||
raise ValueError("Only tabular LaTeX environment is supported")
|
||||
|
||||
def extractMath(TexMath,Soup=False,commands=[]):
|
||||
if not Soup and len(commands)>0:
|
||||
raise ValueError("Commandw are only usable when Soup is True")
|
||||
math=TexMath.find("$")
|
||||
lst=list(math.contents)
|
||||
mystr=str(lst[0])
|
||||
if not Soup:
|
||||
return mystr
|
||||
mathsoup=None
|
||||
try:
|
||||
mathsoup=TexSoup(mystr)
|
||||
except:
|
||||
raise ValueError(f"Error when parsing latex math: {mystr}")
|
||||
newCommand.runAll(mathsoup,commands)
|
||||
return mathsoup
|
@ -1,6 +1,6 @@
|
||||
from collections import OrderedDict
|
||||
from TexSoup import TexSoup
|
||||
from .LaTeX import newCommand
|
||||
from .LaTeX import newCommand,extractMath
|
||||
from .utils import getValFromCell,checkFloat
|
||||
from TexSoup import TexNode,TexEnv
|
||||
from enum import IntEnum,auto,unique,IntFlag
|
||||
@ -67,17 +67,7 @@ class dataFileBase(object):
|
||||
def convertState(StateTablelist,initialState,default=DataType.ABS,commands=[]):
|
||||
tmplst=[]
|
||||
for TexState in StateTablelist:
|
||||
math=TexState.find("$")
|
||||
lst=list(math.contents)
|
||||
mystr=str(lst[0])
|
||||
mathsoup=None
|
||||
try:
|
||||
mathsoup=TexSoup(mystr)
|
||||
except:
|
||||
print(f"Error when parsing latex state: {mystr}")
|
||||
exit(-1)
|
||||
newCommand.runAll(mathsoup,commands)
|
||||
st=str(mathsoup)
|
||||
st=str(extractMath(TexState,Soup=True,commands=commands))
|
||||
m=re.match(r"^\^(?P<multiplicity>\d)(?P<symm>[^\s\[(]*)\s*(?:\[(?:\\mathrm{)?(?P<special>\w)(?:})\])?\s*(:?\((?P<type>[^\)]*)\))?",st)
|
||||
seq=m.group("multiplicity","symm")
|
||||
mul=int(m.group("multiplicity"))
|
||||
|
Loading…
Reference in New Issue
Block a user