lhtml-markup 2.0.1__tar.gz → 2.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. {lhtml_markup-2.0.1/src/lhtml_markup.egg-info → lhtml_markup-2.1.0}/PKG-INFO +1 -1
  2. {lhtml_markup-2.0.1 → lhtml_markup-2.1.0}/pyproject.toml +1 -1
  3. lhtml_markup-2.1.0/src/lhtml/cli.py +98 -0
  4. {lhtml_markup-2.0.1 → lhtml_markup-2.1.0/src/lhtml_markup.egg-info}/PKG-INFO +1 -1
  5. lhtml_markup-2.0.1/src/lhtml/cli.py +0 -62
  6. {lhtml_markup-2.0.1 → lhtml_markup-2.1.0}/LICENSE.md +0 -0
  7. {lhtml_markup-2.0.1 → lhtml_markup-2.1.0}/README.md +0 -0
  8. {lhtml_markup-2.0.1 → lhtml_markup-2.1.0}/setup.cfg +0 -0
  9. {lhtml_markup-2.0.1 → lhtml_markup-2.1.0}/src/lhtml/__init__.py +0 -0
  10. {lhtml_markup-2.0.1 → lhtml_markup-2.1.0}/src/lhtml/__main__.py +0 -0
  11. {lhtml_markup-2.0.1 → lhtml_markup-2.1.0}/src/lhtml/ast_nodes.py +0 -0
  12. {lhtml_markup-2.0.1 → lhtml_markup-2.1.0}/src/lhtml/code.py +0 -0
  13. {lhtml_markup-2.0.1 → lhtml_markup-2.1.0}/src/lhtml/element_extract.py +0 -0
  14. {lhtml_markup-2.0.1 → lhtml_markup-2.1.0}/src/lhtml/errors.py +0 -0
  15. {lhtml_markup-2.0.1 → lhtml_markup-2.1.0}/src/lhtml/export_html.py +0 -0
  16. {lhtml_markup-2.0.1 → lhtml_markup-2.1.0}/src/lhtml/insert_in_text.py +0 -0
  17. {lhtml_markup-2.0.1 → lhtml_markup-2.1.0}/src/lhtml/listing.py +0 -0
  18. {lhtml_markup-2.0.1 → lhtml_markup-2.1.0}/src/lhtml/patterns.py +0 -0
  19. {lhtml_markup-2.0.1 → lhtml_markup-2.1.0}/src/lhtml/pipeline.py +0 -0
  20. {lhtml_markup-2.0.1 → lhtml_markup-2.1.0}/src/lhtml/process.py +0 -0
  21. {lhtml_markup-2.0.1 → lhtml_markup-2.1.0}/src/lhtml/tag_element.lark +0 -0
  22. {lhtml_markup-2.0.1 → lhtml_markup-2.1.0}/src/lhtml/tag_parser.py +0 -0
  23. {lhtml_markup-2.0.1 → lhtml_markup-2.1.0}/src/lhtml/wrap_html.py +0 -0
  24. {lhtml_markup-2.0.1 → lhtml_markup-2.1.0}/src/lhtml_markup.egg-info/SOURCES.txt +0 -0
  25. {lhtml_markup-2.0.1 → lhtml_markup-2.1.0}/src/lhtml_markup.egg-info/dependency_links.txt +0 -0
  26. {lhtml_markup-2.0.1 → lhtml_markup-2.1.0}/src/lhtml_markup.egg-info/entry_points.txt +0 -0
  27. {lhtml_markup-2.0.1 → lhtml_markup-2.1.0}/src/lhtml_markup.egg-info/requires.txt +0 -0
  28. {lhtml_markup-2.0.1 → lhtml_markup-2.1.0}/src/lhtml_markup.egg-info/top_level.txt +0 -0
  29. {lhtml_markup-2.0.1 → lhtml_markup-2.1.0}/test/test_lhtml.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lhtml-markup
3
- Version: 2.0.1
3
+ Version: 2.1.0
4
4
  Summary: Lightweight HTML markup language — simplifies HTML authoring with shorthand syntax
5
5
  License: MIT
6
6
  Project-URL: Homepage, https://github.com/drohmer/lhtml
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "lhtml-markup"
7
- version = "2.0.1"
7
+ version = "2.1.0"
8
8
  description = "Lightweight HTML markup language — simplifies HTML authoring with shorthand syntax"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
@@ -0,0 +1,98 @@
1
+ """LHTML command-line interface.
2
+
3
+ Usage:
4
+ lhtml [-w] file.l.html # Single file → stdout
5
+ lhtml [-w] file.l.html -o output.html # Single file → output file
6
+ lhtml [-w] a.l.html b.l.html # Multiple files → .html next to sources
7
+ lhtml [-w] a.l.html b.l.html -o build/ # Multiple files → output directory
8
+ python -m lhtml [same options]
9
+ """
10
+
11
+ import os
12
+ import argparse
13
+
14
+ from .pipeline import ProcessingPipeline
15
+
16
+
17
+ _pipeline = ProcessingPipeline()
18
+
19
+
20
+ def _ensure_trailing_newline(text):
21
+ if text and text[-1] != '\n':
22
+ return text + '\n'
23
+ return text
24
+
25
+
26
+ def _output_path_for(input_path, output_arg):
27
+ """Determine the output path for a given input file.
28
+
29
+ If output_arg is a directory, write <dir>/<basename>.html.
30
+ If output_arg is a file path, return it directly (single-file mode).
31
+ If output_arg is None, derive .html from the input path.
32
+ """
33
+ basename = os.path.basename(input_path)
34
+ name, _ = os.path.splitext(basename)
35
+ # Strip double extensions like .l.html → .html
36
+ if name.endswith('.l'):
37
+ name = name[:-2]
38
+
39
+ if output_arg is None:
40
+ # Write next to source
41
+ return os.path.join(os.path.dirname(input_path), name + '.html')
42
+
43
+ if os.path.isdir(output_arg) or output_arg.endswith('/'):
44
+ os.makedirs(output_arg, exist_ok=True)
45
+ return os.path.join(output_arg, name + '.html')
46
+
47
+ # Treat as a direct file path (single-file mode)
48
+ return output_arg
49
+
50
+
51
+ def _process_file(f_in, meta_base):
52
+ """Process a single LHTML file and return the HTML output."""
53
+ meta = dict(meta_base)
54
+ dir_to_include = os.path.dirname(os.path.abspath(f_in))
55
+ if dir_to_include:
56
+ meta['directory_include'] = meta.get('directory_include', []) + [dir_to_include + '/']
57
+
58
+ with open(f_in) as fid:
59
+ txt = _ensure_trailing_newline(fid.read())
60
+
61
+ return _ensure_trailing_newline(_pipeline.run(txt, meta))
62
+
63
+
64
+ def main():
65
+ """CLI entry point."""
66
+ parser = argparse.ArgumentParser(description='Lightweight HTML')
67
+ parser.add_argument('inputFiles', nargs='+', help='Input file(s)')
68
+ parser.add_argument('-w', '--wrapAuto',
69
+ help='Wrap content in basic HTML template',
70
+ action='store_true')
71
+ parser.add_argument('-o', '--output',
72
+ help='Output file (single input) or directory (multiple inputs)')
73
+ args = parser.parse_args()
74
+
75
+ meta = {'directory_include': [os.getcwd() + '/']}
76
+ if args.wrapAuto:
77
+ meta['wrap-auto'] = True
78
+
79
+ single_file = len(args.inputFiles) == 1
80
+ single_to_stdout = single_file and args.output is None
81
+
82
+ for f_in in args.inputFiles:
83
+ if not os.path.isfile(f_in):
84
+ print(f'Error: file not found [{f_in}]')
85
+ continue
86
+
87
+ html = _process_file(f_in, meta)
88
+
89
+ if single_to_stdout:
90
+ print(html)
91
+ else:
92
+ out_path = _output_path_for(f_in, args.output)
93
+ with open(out_path, 'w') as f_out:
94
+ f_out.write(html)
95
+
96
+
97
+ if __name__ == '__main__':
98
+ main()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lhtml-markup
3
- Version: 2.0.1
3
+ Version: 2.1.0
4
4
  Summary: Lightweight HTML markup language — simplifies HTML authoring with shorthand syntax
5
5
  License: MIT
6
6
  Project-URL: Homepage, https://github.com/drohmer/lhtml
@@ -1,62 +0,0 @@
1
- """LHTML command-line interface.
2
-
3
- Usage:
4
- lhtml [-w] inputFile [-o outputFile]
5
- python -m lhtml [-w] inputFile [-o outputFile]
6
- """
7
-
8
- import os
9
- import argparse
10
-
11
- from .pipeline import ProcessingPipeline
12
-
13
-
14
- _pipeline = ProcessingPipeline()
15
-
16
-
17
- def _ensure_trailing_newline(text):
18
- if text and text[-1] != '\n':
19
- return text + '\n'
20
- return text
21
-
22
-
23
- def main():
24
- """CLI entry point."""
25
- parser = argparse.ArgumentParser(description='Lightweight HTML')
26
- parser.add_argument('inputFile', help='Input filepath')
27
- parser.add_argument('-w', '--wrapAuto',
28
- help='Wrap content in basic HTML template',
29
- action='store_true')
30
- parser.add_argument('-o', '--outputFile', help='Output filepath')
31
- args = parser.parse_args()
32
-
33
- meta = {}
34
- if args.wrapAuto:
35
- meta['wrap-auto'] = True
36
-
37
- meta['directory_include'] = [os.getcwd() + '/']
38
- f_in = args.inputFile
39
-
40
- if os.path.isfile(f_in):
41
- dir_to_include = os.path.dirname(f_in)
42
- if dir_to_include:
43
- meta['directory_include'].append(
44
- os.path.join(os.getcwd(), dir_to_include) + '/'
45
- )
46
-
47
- with open(f_in) as fid:
48
- txt = _ensure_trailing_newline(fid.read())
49
-
50
- html = _ensure_trailing_newline(_pipeline.run(txt, meta))
51
-
52
- if args.outputFile:
53
- with open(args.outputFile, 'w') as f_out:
54
- f_out.write(html)
55
- else:
56
- print(html)
57
- else:
58
- print(f'Error: unrecognized input file [{f_in}]')
59
-
60
-
61
- if __name__ == '__main__':
62
- main()
File without changes
File without changes
File without changes