diff --git a/.gitignore b/.gitignore
index ea8c4bf..fbe4996 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
/target
+/output
diff --git a/Cargo.lock b/Cargo.lock
index c0b1e47..08a0387 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -533,7 +533,7 @@ dependencies = [
[[package]]
name = "risp"
version = "0.1.0"
-source = "git+ssh://git@git.hofer.link:2222/philipp/risp.git#324df0568aa8430985d303187885441dcb5e9bf3"
+source = "git+https://git.hofer.link/philipp/risp.git#3bc0a005174075172eeac1d0f5f2ef8708f375e0"
dependencies = [
"clap",
"directories",
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..e7b6af6
--- /dev/null
+++ b/README.md
@@ -0,0 +1,7 @@
+```
+
+ What is CSS
+ Cascading Style Sheets.
+
+```:q
+
diff --git a/data/abgb.toml b/laws/abgb.toml
similarity index 100%
rename from data/abgb.toml
rename to laws/abgb.toml
diff --git a/laws/eheg.toml b/laws/eheg.toml
new file mode 100644
index 0000000..7d93555
--- /dev/null
+++ b/laws/eheg.toml
@@ -0,0 +1,56 @@
+[law]
+id = 10001871
+
+[[law.classifiers]]
+name = "Abschnitt"
+is_root = true
+match_function = "contains"
+
+[[law.classifiers]]
+name = "Uppercase letter"
+is_root = false
+match_function = "starts_with_uppercaseletter"
+
+[[law.classifiers]]
+name = "roman letter"
+is_root = false
+match_function = "starts_with_roman_number"
+
+[[law.classifiers]]
+name = "letter"
+is_root = false
+match_function = "starts_with_letter"
+
+[parser]
+remove_strings = [
+ """§ 33""",
+ "", "",
+ "", ""
+]
+move_para_headers_into_content = true
+
+
+[[parser.replace_rules]]
+find = ""
+replace_with = "-"
+
+[[parser.replace_rules]]
+find = "(Anm.: § 108 aufgehoben durch Art. II Z 7 BGBl. Nr. 566/1983)"
+replace_with = "§ 108.(Anm.: § 108 aufgehoben durch Art. II Z 7 BGBl. Nr. 566/1983)"
+
+# Wrongly formatted "headers"
+[[parser.replace_rules]]
+find = """Fristablauf"""
+replace_with = """Fristablauf"""
+
+[[parser.replace_rules]]
+find = """I. Nichtigkeitsgründe"""
+replace_with = """I. Nichtigkeitsgründe"""
+
+[[parser.replace_rules]]
+find = """I. Allgemeine Vorschriften"""
+replace_with = """I. Allgemeine Vorschriften"""
+
+[[parser.replace_rules]]
+find = """I. Name der geschiedenen Frau"""
+replace_with = """I. Name der geschiedenen Frau"""
diff --git a/laws/kschg.toml b/laws/kschg.toml
new file mode 100644
index 0000000..a856e90
--- /dev/null
+++ b/laws/kschg.toml
@@ -0,0 +1,15 @@
+[law]
+id = 10002462
+
+[[law.classifiers]]
+name = "Hauptstück"
+is_root = true
+match_function = "contains"
+
+[[law.classifiers]]
+name = "Abschnitt"
+is_root = false
+match_function = "contains"
+
+[parser]
+remove_strings = ["", ""]
diff --git a/laws/mschg.toml b/laws/mschg.toml
new file mode 100644
index 0000000..bfd1a89
--- /dev/null
+++ b/laws/mschg.toml
@@ -0,0 +1,32 @@
+[law]
+id = 10002180
+
+[[law.classifiers]]
+name = "Abschnitt"
+is_root = true
+match_function = "contains"
+
+[[law.classifiers]]
+name = "Number"
+is_root = false
+match_function = "starts_with_number"
+
+[parser]
+remove_strings = ["", ""]
+
+[[parser.replace_rules]]
+find = "bis"
+replace_with = "bis"
+
+[[parser.replace_rules]]
+find = "ter"
+replace_with = "ter"
+
+[[parser.replace_rules]]
+find = ""
+replace_with = "-"
+
+[[parser.replace_rules]]
+find = "(Anm.: § 69 aufgehoben durch Art. 1 Z 12, BGBl. I Nr. 124/2017)"
+replace_with = "§ 69.(Anm.: § 69 aufgehoben durch Art. 1 Z 12, BGBl. I Nr. 124/2017)"
+
diff --git a/laws/schifffahrtsg.toml b/laws/schifffahrtsg.toml
new file mode 100644
index 0000000..bd0bc5f
--- /dev/null
+++ b/laws/schifffahrtsg.toml
@@ -0,0 +1,29 @@
+[law]
+id = 10012703
+
+[[law.classifiers]]
+name = "Teil"
+is_root = true
+match_function = "contains"
+
+[[law.classifiers]]
+name = "Hauptstück"
+is_root = false
+match_function = "contains"
+
+[parser]
+remove_strings = [
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "" # this is a nice one, have a look at § 133 (2) Zi. 5 and enjoy :^)
+]
+
+
+[[parser.replace_rules]]
+find = ""
+replace_with = "-"
+
diff --git a/laws/stgb.toml b/laws/stgb.toml
new file mode 100644
index 0000000..4472c82
--- /dev/null
+++ b/laws/stgb.toml
@@ -0,0 +1,42 @@
+[law]
+id = 10002296
+
+[[law.classifiers]]
+name = "Teil"
+is_root = true
+match_function = "contains"
+
+[[law.classifiers]]
+name = "Abschnitt"
+is_root = false
+match_function = "contains"
+
+[parser]
+remove_strings = [
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ """"""
+]
+
+[[parser.replace_rules]]
+find = """Erster Abschnitt"""
+replace_with = """Erster Abschnitt"""
+
+[[parser.replace_rules]]
+find = """Allgemeine Bestimmungen"""
+replace_with = """Allgemeine Bestimmungen"""
+
+[[parser.replace_rules]]
+find = """1. Verwertungsrechte."""
+replace_with = """1. Verwertungsrechte."""
+
+[[parser.replace_rules]]
+find = """Strafbare Handlungen gegen Leib und Leben"""
+replace_with = """Strafbare Handlungen gegen Leib und Leben"""
+
+[[parser.replace_rules]]
+find = ""
+replace_with = "-"
+
diff --git a/laws/teg.toml b/laws/teg.toml
new file mode 100644
index 0000000..c810da3
--- /dev/null
+++ b/laws/teg.toml
@@ -0,0 +1,18 @@
+[law]
+id = 10001905
+
+[[law.classifiers]]
+name = "Abschnitt"
+is_root = true
+match_function = "contains"
+
+[parser]
+remove_strings = [
+ """(§§ 1, 2, 3, 4,6, § 8 Abs. 1 und 2 des Gesetzes vom 16. Februar 1883, RGBl. Nr. 20, betreffend das Verfahren zum Zwecke der Todeserklärung und der Beweisführung des Todes, in der Fassung des Gesetzes vom 31. März 1918, RGBl. Nr. 129:)""",
+ """(§§ 1 bis 11 des Gesetzes über die Verschollenheit, die Todeserklärung und die Feststellung der Todeszeit vom 4. Juli 1939, Deutsches RGBl. I S. 1186:)""",
+ """(§ 56 Abs. 3 des Gesetzes vom 4. Juli 1939, Deutsches RGBl. I S. 1186:)""",
+ """(§ 10 des Gesetzes vom 16. Februar 1883, RGBl. Nr. 20, betreffend das Verfahren zum Zwecke der Todeserklärung und der Beweisführung des Todes, in der Fassung des Gesetzes vom 31. März 1918, RGBl. Nr. 129:)""",
+ """(§§ 10a, 10b und 10c des Gesetzes vom 16. Februar 1883, RGBl. Nr. 20, betreffend das Verfahren zum Zwecke der Todeserklärung und der Beweisführung des Todes, in der Fassung des Gesetzes vom 31. März 1918, RGBl. Nr. 129:)""",
+ "", ""
+]
+
diff --git a/laws/urhg.toml b/laws/urhg.toml
new file mode 100644
index 0000000..a12673d
--- /dev/null
+++ b/laws/urhg.toml
@@ -0,0 +1,29 @@
+[law]
+id = 10001848
+
+[[law.classifiers]]
+name = "Hauptstück"
+is_root = true
+match_function = "contains"
+
+[[law.classifiers]]
+name = "Abschnitt"
+is_root = false
+match_function = "contains"
+
+[[law.classifiers]]
+name = "Number"
+is_root = false
+match_function = "starts_with_number"
+
+[[parser.replace_rules]]
+find = "."
+replace_with = "."
+
+[[parser.replace_rules]]
+find = ""
+replace_with = "-"
+
+[[parser.replace_rules]]
+find = """(2) Einer Rundfunksendung steht es gleich, wenn ein Werk von einer im In- oder im Ausland gelegenen Stelle aus der Öffentlichkeit im Inland, ähnlich wie durch Rundfunk, aber mit Hilfe von Leitungen wahrnehmbar gemacht wird."""
+replace_with = """(2) Einer Rundfunksendung steht es gleich, wenn ein Werk von einer im In- oder im Ausland gelegenen Stelle aus der Öffentlichkeit im Inland, ähnlich wie durch Rundfunk, aber mit Hilfe von Leitungen wahrnehmbar gemacht wird."""
diff --git a/laws/vereinsg.toml b/laws/vereinsg.toml
new file mode 100644
index 0000000..21b27a7
--- /dev/null
+++ b/laws/vereinsg.toml
@@ -0,0 +1,16 @@
+[law]
+id = 20001917
+
+[[law.classifiers]]
+name = "Abschnitt"
+is_root = true
+match_function = "contains"
+
+[parser]
+remove_strings = ["", ""]
+
+
+[[parser.replace_rules]]
+find = ""
+replace_with = "-"
+
diff --git a/laws/vgg.toml b/laws/vgg.toml
new file mode 100644
index 0000000..5de77ea
--- /dev/null
+++ b/laws/vgg.toml
@@ -0,0 +1,7 @@
+[law]
+id = 20011654
+
+[[law.classifiers]]
+name = "Abschnitt"
+is_root = true
+match_function = "contains"
diff --git a/src/main.rs b/src/main.rs
index 8cc0d33..57c9112 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,27 +1,99 @@
-use risp::law::{Heading, HeadingContent, Law};
+use std::fs;
-fn print_header(header: Heading, level: usize) {
+use risp::law::{Content, Heading, HeadingContent, Law, Section};
+
+fn print_content(content: Content) -> String {
+ let mut ret = String::new();
+
+ match content {
+ Content::Text(t) => ret.push_str(&format!("
{t}
")),
+ Content::Item(l) | Content::List(l) => {
+ ret.push_str("");
+ for item in l {
+ ret.push_str(&print_content(item));
+ }
+ ret.push_str("");
+ }
+ }
+
+ ret
+}
+
+fn print_paragraph(section: Section) -> String {
+ let mut ret = String::new();
+ ret.push_str("");
+ ret.push_str(&format!("{}", section.symb));
+ if let Some(par_header) = section.par_header {
+ ret.push_str(&format!("", par_header));
+ }
+ if let Some(note) = section.par_note {
+ ret.push_str(&format!("Beachte: {}", note));
+ }
+ ret.push_str(&print_content(section.content));
+
+ ret.push_str("
");
+ ret
+}
+
+fn print_header(header: Heading, level: usize) -> String {
+ let mut ret = String::new();
let mut header_title = header.name.clone();
if let Some(desc) = header.desc {
header_title.push_str(&format!(" ({desc})"))
}
- println!("{} {header_title}", " ".repeat(level));
+ ret.push_str(&format!(
+ "\
+ {1}
\n\
+ ",
+ level + 2,
+ header_title
+ ));
match header.content {
- HeadingContent::Paragraph(p) => {}
+ HeadingContent::Paragraph(p) => {
+ for section in p {
+ ret.push_str(&print_paragraph(section));
+ }
+ }
HeadingContent::Heading(subheaders) => {
for subheader in subheaders {
- print_header(subheader, level + 1);
+ ret.push_str(&print_header(subheader, level + 1));
}
}
}
+
+ ret.push_str("
");
+
+ ret
+}
+
+fn get_content(config_path: &str) -> String {
+ let law = Law::from_config(config_path).unwrap();
+
+ let mut ret = String::new();
+ for h in law.header {
+ ret.push_str(&print_header(h, 0));
+ }
+
+ ret
}
fn main() {
- let law = Law::from_config("data/abgb.toml").unwrap();
+ let configs = fs::read_dir("./laws").expect("No folder with config files");
- for h in law.header {
- print_header(h, 0);
+ for config in configs {
+ let config = config.unwrap();
+ let filename = config.file_name().into_string().unwrap();
+ //TODO: use proper logic...
+ let law_name = filename.replace(".toml", "");
+
+ let path = format!("{}", config.path().display());
+ let content = get_content(&path);
+
+ let template = fs::read_to_string("templates/index.html").unwrap();
+ let site = template.replace("{{content}}", &content);
+
+ fs::write(&format!("output/{law_name}.html"), &site).expect("Unable to write file");
}
}
diff --git a/templates/index.html b/templates/index.html
new file mode 100644
index 0000000..2db609c
--- /dev/null
+++ b/templates/index.html
@@ -0,0 +1,13 @@
+
+
+
+
+
+ ABGB
+ {{content}}
+
+