예제 #1
0
파일: dokuwiki.py 프로젝트: huddy1985/Thot
def handleFigure(man, match):
    image = match.group("image")
    width = match.group("image_width")
    if width != None:
        width = int(width)
    height = match.group("image_height")
    if height != None:
        height = int(height)
    label = match.group("image_label")
    if label == None:
        caption = None
    else:
        caption = doc.Par()
        caption.append(doc.Word(label))
    left = len(match.group("left"))
    right = len(match.group("right"))
    if left == right:
        align = doc.ALIGN_CENTER
    elif left > right:
        align = doc.ALIGN_RIGHT
    else:
        align = doc.ALIGN_LEFT
    man.send(
        doc.ObjectEvent(doc.L_PAR, doc.ID_NEW,
                        doc.Figure(image, width, height, caption, align)))
예제 #2
0
def handleCaption(man, match):
    par = doc.Par()
    man.push(par)
    man.getParser().parse(man, match.group(1))
    while par != man.get():
        man.pop()
    man.pop()
    for item in man.iter():
        if item.setCaption(par):
            return
    raise common.ParseException("caption unsupported here")
예제 #3
0
파일: textile.py 프로젝트: huddy1985/Thot
def new_image(man, match):
    tmatch = match
    image = match.group('image')

    # alt pealing
    alt = None
    if image[-1] == ')':
        i = image.rfind('(')
        if i >= 0:
            label = image[i + 1:-1]
            alt = doc.Par()
            alt.append(doc.Word(label))
            image = image[:i]

    # style pealing
    info = doc.Info()
    image = use_par_style(info, image)

    # dimension pealing
    match = WXH_RE.search(image)
    if match:
        info.setInfo(doc.INFO_WIDTH, int(match.group(1)))
        info.setInfo(doc.INFO_HEIGHT, int(match.group(2)))
        image = image[:match.start()]
    else:
        match = WH_RE.search(image)
        if match:
            info.setInfo(doc.INFO_WIDTH, int(match.group(1)))
            info.setInfo(doc.INFO_HEIGHT, int(match.group(2)))
            image = image[:match.start()]
        else:
            match = PERCENT_RE.search(image)
            if match:
                info.setInfo(doc.INFO_PERCENT_SIZE, int(match.group(1)))
                image = image[:match.start()]

    # beginning link if any
    link = tmatch.group('iurl')
    if link:
        man.send(doc.ObjectEvent(doc.L_WORD, doc.ID_NEW_LINK, doc.Link(link)))

    # build the image
    if info.getInfo(doc.INFO_ALIGN):
        node = doc.Image(image, None, None, alt)
    else:
        node = doc.Figure(image, None, None, alt)
    node.mergeInfo(info)
    man.send(doc.ObjectEvent(doc.L_WORD, doc.ID_NEW, node))

    # end link
    if link:
        man.send(doc.CloseEvent(doc.L_WORD, doc.ID_END_LINK, "link"))
예제 #4
0
파일: dokuwiki.py 프로젝트: huddy1985/Thot
def handleImage(man, match):
    if match.group("left") or match.group("right"):
        handleFigure(man, match)
    else:
        image = match.group("image")
        width = match.group("image_width")
        if width != None:
            width = int(width)
        height = match.group("image_height")
        if height != None:
            height = int(height)
        label = match.group("image_label")
        if label == None:
            caption = None
        else:
            caption = doc.Par()
            caption.append(doc.Word(label))
        man.send(
            doc.ObjectEvent(doc.L_WORD, doc.ID_NEW,
                            doc.Image(image, width, height, caption)))
예제 #5
0
def handle_new_par(man, match):
    man.send(doc.ObjectEvent(doc.L_PAR, doc.ID_END, doc.Par()))
예제 #6
0
파일: textile.py 프로젝트: huddy1985/Thot
def new_single_blockquote(man, match):
    bq = BlockQuote()
    use_par_style(bq, match.group(1))
    man.send(doc.ObjectEvent(doc.L_PAR, doc.ID_END, bq))
    tparser.handleText(man, match.group("text"))
    man.send(doc.ObjectEvent(doc.L_PAR, doc.ID_END, doc.Par()))
예제 #7
0
파일: textile.py 프로젝트: huddy1985/Thot
def new_par_ext(man, match):
    man.send(doc.ObjectEvent(doc.L_PAR, doc.ID_END, doc.Par()))
    use_par_style(man.get(), match.group(1))
    tparser.handleText(man, match.group('text'))
예제 #8
0
파일: dokuwiki.py 프로젝트: huddy1985/Thot
def handleIndent(man, match):
    if match.group(1):
        IndentParser(man, match)
    else:
        man.send(doc.ObjectEvent(doc.L_PAR, doc.ID_END, doc.Par()))