def testOrgParserIdentifyOrgTables(self):
        source = ["some text sdfsdf", "| Header | X | Header Z |", "|------+----+------|", "| Content | 1 | Content Z |", "Some other text"]
        target = (CacheLocation(1,0), CacheLocation(3,27))

        result = OrgParser.identifyOrgTable(source, CacheLocation.getZeroCacheLocation())

        self.assertEqual(result, target)
Esempio n. 2
0
def translateOrgToHTMLTables(pCache):
    vNewCache = pCache
    vCacheRange = OrgParser.identifyOrgTable(vNewCache, CacheLocation.getZeroCacheLocation())
    while(vCacheRange.start != None and vCacheRange.start > CacheLocation.getZeroCacheLocation()):
        vOrgTablePart = CacheLocation.getCacheLocation(vNewCache, vCacheRange.start, vCacheRange.end)
        vOrgTable = OrgParser.parse(vOrgTablePart)
        vHTMLWriter = OrgTableHTMLWriter(vOrgTable)
        vCache = vHTMLWriter.parseHTML()
        vNewCache = CacheLocation.replaceCacheLocation(vNewCache, vCacheRange.start, vCacheRange.end, vCache)

        vOriginalLines = vCacheRange.end.getLineNum() - vCacheRange.start.getLineNum()
        vNewLines = len(vCache)
        vDifference = vNewLines - vOriginalLines        

        vCacheLocationEnd = CacheLocation(vCacheRange.end.getLineNum()+vDifference, vCacheRange.end.getIndex())
        vCacheRange = OrgParser.identifyOrgTable(vNewCache, vCacheLocationEnd)


    return vNewCache