texmacs-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Texmacs-dev] Questions regarding conversion between strings and trees


From: David MENTRE
Subject: [Texmacs-dev] Questions regarding conversion between strings and trees
Date: Sat, 04 Mar 2006 12:46:10 +0100
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux)

Hello,

I'm pursuing the idea of a literate programming mode for texmacs. My
current running code is able to parse (and produce in the reverse
direction) a source file into a Scheme structure like the following one
(" and \ are backquoted in the Scheme way). TM and CODE a two Scheme
symbols representing respectively texmacs document and literate code.

  '((tm . "<TeXmacs|1.0.6>")
    (tm . "")
    (tm . "<style|generic>")
    (tm . "")
    (tm . "<\\body>")
    (tm . "  Sample texmacs document.")
    (tm . "")
    (code . "(define (hello-world) (display \"Hello world!\"))")
    (code . "")
    (tm . "  \;")
    (tm . "</body>")
    (tm . "")
    (tm . "<\\initial>")
    (tm . "  <\\collection>")
    (tm . "    <associate|language|french>")
    (tm . "  </collection>")
    (tm . "</initial>")


I need to transform this data structure into a texmacs document (and in
the reverse way for saving). I would like to keep the CODE blocks into a
specific node type of texmacs document tree.

So my questions:

 1. Is it possible to add a new node type (something like
    <\lp-code></lp-code>) to texmacs tree? How? If it is possible, I
    suppose I need to define a style file for rendering?

 2. How can I convert serialized part of texmacs document into tree data
    structure suitable for inclusion in the current document buffer?
    Apparently, string->tree could be used for this but, from my
    attempts, tags are not interpreted correctly. E.g.:

  (display* (string->tree "<TeXmacs|1.0.6>"))
gives
  <tree \<TeXmacs\|1.0.6\>>
and not an expected
  <tree <TeXmacs|1.0.6>>

    Or maye I don't interpret display* output correctly? In a previous
    email Henri said that (string->tree "<gtr>") produces the expected
    ">" character in TeXmacs but a display* still prints "<tree
    \<gtr\>>" on console.

 3. Moreover, I'm wondering how to handle the issue that opening and
    closing tags (for example <\body> and </body>) are not in the same
    string. One solution would be to:

    a. first convert (code . "toto") lines into 
       (tm . "<\lp-code>toto</lp-code>");

    b. and then concat all the strings to do a big string->tree on the
       final string.

    Is there a better way to do this?

I've read with great interest recent discussion between Lionel and Henri
but I must admit I'm a bit lost in the string successive escapes. ;)

Best wishes,
d.
-- 
pub  1024D/A3AD7A2A 2004-10-03 David MENTRE <address@hidden>
 5996 CC46 4612 9CA4 3562  D7AC 6C67 9E96 A3AD 7A2A





reply via email to

[Prev in Thread] Current Thread [Next in Thread]