[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add KDL parser/generator #55

Open
evgenyigumnov opened this issue May 7, 2024 · 0 comments
Open

Add KDL parser/generator #55

evgenyigumnov opened this issue May 7, 2024 · 0 comments
Assignees

Comments

@evgenyigumnov
Copy link
Member
evgenyigumnov commented May 7, 2024
  1. use crate:

kdl = "4.6.0"

  1. create kdl.rs in "lib/src"

  2. implement this trait

pub trait TransformerTrait {
    fn parse(document: &Bytes, images: &HashMap<String, Bytes>) -> anyhow::Result<Document>;
    fn generate(document: &Document) -> anyhow::Result<(Bytes, HashMap<String, Bytes>)>;
}

just check html.rs for example

example of KDL document:

document page_width=210.0 page_height=297.0 left_page_indent=10.0 right_page_indent=10.0 top_page_indent=10.0 bottom_page_indent=10.0 {
    elements {
        header level=1 "Employee Report"
        image src="data/logo.png" title="Some title" alt="Some alt"
        paragraph {
            text size=8 "blabla bla bla blabla bla bla blabla bla bla blabla bla bla bla"
            text size=8 "other text"
        }
        list numbered=true {
            text size=8 "First item"
            text size=8 "Second item"
            list numbered=true {
                text size=8 "3rd item"
                text size=8 "4th item"
            }
        }
        header level=2 "Second header"
        table {
            table_header width=150 {
                text size=8 "Name"
            }
            table_header width=50 {
                text size=8 "Salary"
            }
            row {
                cel {
                    text size=8 "John"
                }
                cel {
                    text size=8 "1000"
                }
            }
            row {
                cel {
                    text size=8 "Tommi"
                }
                cel {
                    text size=8 "3000"
                }
            }
        }
        paragraph {
            text size=8 "Some link: "
            link title="http://example.com" url="http://example.com" alt="http://example.com" size=8
        }
    }
    page_header {
        paragraph {
            text size=8 "Page header"
        }
    }
    page_footer {
        paragraph {
            text size=8 "Page footer"
        }
    }
}
@rakurame96 rakurame96 removed their assignment Aug 17, 2024
@joserochadocarmo joserochadocarmo self-assigned this Sep 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

No branches or pull requests

3 participants