ophinode 0.0.1a1__py3-none-any.whl → 0.0.1a3__py3-none-any.whl
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.
- ophinode/nodes/html.py +136 -1
- {ophinode-0.0.1a1.dist-info → ophinode-0.0.1a3.dist-info}/METADATA +2 -2
- {ophinode-0.0.1a1.dist-info → ophinode-0.0.1a3.dist-info}/RECORD +5 -5
- {ophinode-0.0.1a1.dist-info → ophinode-0.0.1a3.dist-info}/WHEEL +0 -0
- {ophinode-0.0.1a1.dist-info → ophinode-0.0.1a3.dist-info}/licenses/LICENSE +0 -0
ophinode/nodes/html.py
CHANGED
@@ -199,9 +199,14 @@ class OpenElement(Element, OpenRenderable, Expandable, Preparable):
|
|
199
199
|
def __init__(
|
200
200
|
self,
|
201
201
|
*args,
|
202
|
+
cls = None,
|
203
|
+
className = None,
|
202
204
|
class_name = None,
|
205
|
+
htmlFor = None,
|
203
206
|
html_for = None,
|
207
|
+
htmlAs = None,
|
204
208
|
html_as = None,
|
209
|
+
htmlAsync = None,
|
205
210
|
html_async = None,
|
206
211
|
accept_charset = None,
|
207
212
|
escape_ampersands = None,
|
@@ -214,12 +219,22 @@ class OpenElement(Element, OpenRenderable, Expandable, Preparable):
|
|
214
219
|
for c in children:
|
215
220
|
self._children.append(c)
|
216
221
|
self._attributes = dict(kwargs)
|
222
|
+
if cls is not None:
|
223
|
+
self._attributes["class"] = cls
|
224
|
+
if className is not None:
|
225
|
+
self._attributes["class"] = className
|
217
226
|
if class_name is not None:
|
218
227
|
self._attributes["class"] = class_name
|
228
|
+
if htmlFor is not None:
|
229
|
+
self._attributes["for"] = htmlFor
|
219
230
|
if html_for is not None:
|
220
231
|
self._attributes["for"] = html_for
|
232
|
+
if htmlAs is not None:
|
233
|
+
self._attributes["as"] = htmlAs
|
221
234
|
if html_as is not None:
|
222
235
|
self._attributes["as"] = html_as
|
236
|
+
if htmlAsync is not None:
|
237
|
+
self._attributes["async"] = htmlAsync
|
223
238
|
if html_async is not None:
|
224
239
|
self._attributes["async"] = html_async
|
225
240
|
if accept_charset is not None:
|
@@ -273,9 +288,14 @@ class ClosedElement(Element, ClosedRenderable):
|
|
273
288
|
def __init__(
|
274
289
|
self,
|
275
290
|
*,
|
291
|
+
cls = None,
|
292
|
+
className = None,
|
276
293
|
class_name = None,
|
294
|
+
htmlFor = None,
|
277
295
|
html_for = None,
|
296
|
+
htmlAs = None,
|
278
297
|
html_as = None,
|
298
|
+
htmlAsync = None,
|
279
299
|
html_async = None,
|
280
300
|
accept_charset = None,
|
281
301
|
escape_ampersands = None,
|
@@ -283,12 +303,22 @@ class ClosedElement(Element, ClosedRenderable):
|
|
283
303
|
**kwargs
|
284
304
|
):
|
285
305
|
self._attributes = dict(kwargs)
|
306
|
+
if cls is not None:
|
307
|
+
self._attributes["class"] = cls
|
308
|
+
if className is not None:
|
309
|
+
self._attributes["class"] = className
|
286
310
|
if class_name is not None:
|
287
311
|
self._attributes["class"] = class_name
|
312
|
+
if htmlFor is not None:
|
313
|
+
self._attributes["for"] = htmlFor
|
288
314
|
if html_for is not None:
|
289
315
|
self._attributes["for"] = html_for
|
316
|
+
if htmlAs is not None:
|
317
|
+
self._attributes["as"] = htmlAs
|
290
318
|
if html_as is not None:
|
291
319
|
self._attributes["as"] = html_as
|
320
|
+
if htmlAsync is not None:
|
321
|
+
self._attributes["async"] = htmlAsync
|
292
322
|
if html_async is not None:
|
293
323
|
self._attributes["async"] = html_async
|
294
324
|
if accept_charset is not None:
|
@@ -330,6 +360,33 @@ class MetaElement(ClosedElement):
|
|
330
360
|
class StyleElement(OpenElement):
|
331
361
|
tag = "style"
|
332
362
|
|
363
|
+
def __init__(self, *args, escape_tag_delimiters = None, **kwargs):
|
364
|
+
if escape_tag_delimiters is None:
|
365
|
+
# stylesheets might contain angle brackets, so it is better to
|
366
|
+
# disable tag delimiter escaping by default
|
367
|
+
escape_tag_delimiters = False
|
368
|
+
super().__init__(
|
369
|
+
*args,
|
370
|
+
escape_tag_delimiters=escape_tag_delimiters,
|
371
|
+
**kwargs
|
372
|
+
)
|
373
|
+
|
374
|
+
def expand(self, context: "ophinode.rendering.RenderContext"):
|
375
|
+
expansion = []
|
376
|
+
for c in self._children:
|
377
|
+
if isinstance(c, str):
|
378
|
+
# Stylesheets might contain "</style", so it must be escaped
|
379
|
+
content = c.replace("</script", "\\3C/script")
|
380
|
+
node = TextNode(content)
|
381
|
+
if self._escape_ampersands is not None:
|
382
|
+
node.escape_ampersands(self._escape_ampersands)
|
383
|
+
if self._escape_tag_delimiters is not None:
|
384
|
+
node.escape_tag_delimiters(self._escape_tag_delimiters)
|
385
|
+
expansion.append(node)
|
386
|
+
else:
|
387
|
+
expansion.append(c)
|
388
|
+
return expansion
|
389
|
+
|
333
390
|
Head = HeadElement
|
334
391
|
Title = TitleElement
|
335
392
|
Base = BaseElement
|
@@ -402,6 +459,7 @@ H4 = HeadingLevel4Element
|
|
402
459
|
H5 = HeadingLevel5Element
|
403
460
|
H6 = HeadingLevel6Element
|
404
461
|
HGroup = HeadingGroupElement
|
462
|
+
Hgroup = HeadingGroupElement
|
405
463
|
Header = HeaderElement
|
406
464
|
Footer = FooterElement
|
407
465
|
Address = AddressElement
|
@@ -462,17 +520,26 @@ class DivisionElement(OpenElement):
|
|
462
520
|
|
463
521
|
P = ParagraphElement
|
464
522
|
HR = HorizontalRuleElement
|
523
|
+
Hr = HorizontalRuleElement
|
465
524
|
Pre = PreformattedTextElement
|
466
525
|
BlockQuote = BlockQuotationElement
|
526
|
+
Blockquote = BlockQuotationElement
|
467
527
|
OL = OrderedListElement
|
528
|
+
Ol = OrderedListElement
|
468
529
|
UL = UnorderedListElement
|
530
|
+
Ul = UnorderedListElement
|
469
531
|
Menu = MenuElement
|
470
532
|
LI = ListItemElement
|
533
|
+
Li = ListItemElement
|
471
534
|
DL = DescriptionListElement
|
535
|
+
Dl = DescriptionListElement
|
472
536
|
DT = DescriptionTermElement
|
537
|
+
Dt = DescriptionTermElement
|
473
538
|
DD = DescriptionDetailsElement
|
539
|
+
Dd = DescriptionDetailsElement
|
474
540
|
Figure = FigureElement
|
475
541
|
FigCaption = FigureCaptionElement
|
542
|
+
Figcaption = FigureCaptionElement
|
476
543
|
Main = MainElement
|
477
544
|
Search = SearchElement
|
478
545
|
Div = DivisionElement
|
@@ -594,6 +661,7 @@ class LineBreakOpportunityElement(ClosedElement):
|
|
594
661
|
|
595
662
|
A = AnchorElement
|
596
663
|
EM = EmphasisElement
|
664
|
+
Em = EmphasisElement
|
597
665
|
Strong = StrongImportanceElement
|
598
666
|
Small = SmallPrintElement
|
599
667
|
S = StrikethroughElement
|
@@ -603,7 +671,9 @@ Dfn = DefinitionElement
|
|
603
671
|
Abbr = AbbreviationElement
|
604
672
|
Ruby = RubyAnnotationElement
|
605
673
|
RT = RubyTextElement
|
674
|
+
Rt = RubyTextElement
|
606
675
|
RP = RubyParenthesesElement
|
676
|
+
Rp = RubyParenthesesElement
|
607
677
|
Data = DataElement
|
608
678
|
Time = TimeElement
|
609
679
|
Code = CodeElement
|
@@ -617,10 +687,14 @@ B = BoldTextElement
|
|
617
687
|
U = UnarticulatedAnnotationElement
|
618
688
|
Mark = MarkedTextElement
|
619
689
|
BDI = BidirectionalIsolateElement
|
690
|
+
Bdi = BidirectionalIsolateElement
|
620
691
|
BDO = BidirectionalOverrideElement
|
692
|
+
Bdo = BidirectionalOverrideElement
|
621
693
|
Span = SpanElement
|
622
694
|
BR = LineBreakElement
|
695
|
+
Br = LineBreakElement
|
623
696
|
WBR = LineBreakOpportunityElement
|
697
|
+
Wbr = LineBreakOpportunityElement
|
624
698
|
|
625
699
|
# --- Edits ---
|
626
700
|
|
@@ -671,8 +745,9 @@ class ImageMapAreaElement(ClosedElement):
|
|
671
745
|
|
672
746
|
Picture = PictureElement
|
673
747
|
Source = SourceElement
|
674
|
-
|
748
|
+
Img = ImageElement
|
675
749
|
IFrame = InlineFrameElement
|
750
|
+
Iframe = InlineFrameElement
|
676
751
|
Embed = EmbeddedContentElement
|
677
752
|
Object = ExternalObjectElement
|
678
753
|
Video = VideoElement
|
@@ -716,13 +791,20 @@ class TableHeaderCellElement(OpenElement):
|
|
716
791
|
Table = TableElement
|
717
792
|
Caption = TableCaptionElement
|
718
793
|
ColGroup = TableColumnGroupElement
|
794
|
+
Colgroup = TableColumnGroupElement
|
719
795
|
Column = TableColumnElement
|
720
796
|
TBody = TableBodyElement
|
797
|
+
Tbody = TableBodyElement
|
721
798
|
THead = TableHeadElement
|
799
|
+
Thead = TableHeadElement
|
722
800
|
TFoot = TableFootElement
|
801
|
+
Tfoot = TableFootElement
|
723
802
|
TR = TableRowElement
|
803
|
+
Tr = TableRowElement
|
724
804
|
TD = TableDataCellElement
|
805
|
+
Td = TableDataCellElement
|
725
806
|
TH = TableHeaderCellElement
|
807
|
+
Th = TableHeaderCellElement
|
726
808
|
|
727
809
|
# --- Forms ---
|
728
810
|
|
@@ -778,11 +860,14 @@ Input = InputElement
|
|
778
860
|
Button = ButtonElement
|
779
861
|
Select = SelectElement
|
780
862
|
DataList = DataListElement
|
863
|
+
Datalist = DataListElement
|
781
864
|
OptGroup = OptionGroupElement
|
865
|
+
Optgroup = OptionGroupElement
|
782
866
|
Option = OptionElement
|
783
867
|
Progress = ProgressElement
|
784
868
|
Meter = MeterElement
|
785
869
|
FieldSet = FieldSetElement
|
870
|
+
Fieldset = FieldSetElement
|
786
871
|
Legend = FieldSetLegendElement
|
787
872
|
|
788
873
|
# --- Interactive elements ---
|
@@ -806,6 +891,55 @@ Dialog = DialogElement
|
|
806
891
|
class ScriptElement(OpenElement):
|
807
892
|
tag = "script"
|
808
893
|
|
894
|
+
def __init__(self, *args, escape_tag_delimiters = None, **kwargs):
|
895
|
+
if escape_tag_delimiters is None:
|
896
|
+
# javascript code might contain angle brackets,
|
897
|
+
# so it is better to disable tag delimiter escaping by default
|
898
|
+
escape_tag_delimiters = False
|
899
|
+
super().__init__(
|
900
|
+
*args,
|
901
|
+
escape_tag_delimiters=escape_tag_delimiters,
|
902
|
+
**kwargs
|
903
|
+
)
|
904
|
+
|
905
|
+
def expand(self, context: "ophinode.rendering.RenderContext"):
|
906
|
+
expansion = []
|
907
|
+
for c in self._children:
|
908
|
+
if isinstance(c, str):
|
909
|
+
# Due to restrictions for contents of script elements, some
|
910
|
+
# sequences of characters must be replaced before constructing
|
911
|
+
# a script element.
|
912
|
+
#
|
913
|
+
# Unfortunately, correctly replacing such character sequences
|
914
|
+
# require a full lexical analysis on the script content, but
|
915
|
+
# ophinode is currently incapable of doing so.
|
916
|
+
#
|
917
|
+
# However, the sequences are expected to be rarely seen
|
918
|
+
# outside literals, so replacements are done nonetheless.
|
919
|
+
#
|
920
|
+
# This behavior might change in the later versions of ophinode
|
921
|
+
# when it starts to better support inline scripting.
|
922
|
+
#
|
923
|
+
# Read https://html.spec.whatwg.org/multipage/scripting.html#restrictions-for-contents-of-script-elements
|
924
|
+
# for more information.
|
925
|
+
#
|
926
|
+
content = c.replace(
|
927
|
+
"<!--", "\\x3C!--"
|
928
|
+
).replace(
|
929
|
+
"<script", "\\x3Cscript"
|
930
|
+
).replace(
|
931
|
+
"</script", "\\x3C/script"
|
932
|
+
)
|
933
|
+
node = TextNode(content)
|
934
|
+
if self._escape_ampersands is not None:
|
935
|
+
node.escape_ampersands(self._escape_ampersands)
|
936
|
+
if self._escape_tag_delimiters is not None:
|
937
|
+
node.escape_tag_delimiters(self._escape_tag_delimiters)
|
938
|
+
expansion.append(node)
|
939
|
+
else:
|
940
|
+
expansion.append(c)
|
941
|
+
return expansion
|
942
|
+
|
809
943
|
class NoScriptElement(OpenElement):
|
810
944
|
tag = "noscript"
|
811
945
|
|
@@ -820,6 +954,7 @@ class CanvasElement(OpenElement):
|
|
820
954
|
|
821
955
|
Script = ScriptElement
|
822
956
|
NoScript = NoScriptElement
|
957
|
+
Noscript = NoScriptElement
|
823
958
|
Template = TemplateElement
|
824
959
|
Slot = SlotElement
|
825
960
|
Canvas = CanvasElement
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ophinode
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.1a3
|
4
4
|
Summary: A static site generator written in Python
|
5
5
|
Project-URL: Homepage, https://github.com/deflatedlatte/ophinode
|
6
6
|
Project-URL: Issues, https://github.com/deflatedlatte/ophinode/issues
|
@@ -44,7 +44,7 @@ class MainPage:
|
|
44
44
|
Title("Main Page")
|
45
45
|
]
|
46
46
|
|
47
|
-
render_page(MainPage(), HTML5Layout())
|
47
|
+
print(render_page(MainPage(), HTML5Layout()))
|
48
48
|
|
49
49
|
```
|
50
50
|
|
@@ -6,8 +6,8 @@ ophinode/rendering.py,sha256=Q1cxSwXs22Cq40fvbQVhGk3XQQOy1PcZBObSYt7NduQ,6201
|
|
6
6
|
ophinode/site.py,sha256=zpbQOih5YvUUIAi7SqFHveNCWJurGzxjDWbrlW3G07w,16775
|
7
7
|
ophinode/nodes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
8
|
ophinode/nodes/base.py,sha256=SbjN8wjR77G3_8Lvvog4PriTq4v1WnnNr3nzAi0xMto,1004
|
9
|
-
ophinode/nodes/html.py,sha256=
|
10
|
-
ophinode-0.0.
|
11
|
-
ophinode-0.0.
|
12
|
-
ophinode-0.0.
|
13
|
-
ophinode-0.0.
|
9
|
+
ophinode/nodes/html.py,sha256=FEnkFcjqD438hRsZWDMwSrkBrwP8C0wDvqsu-a111Jo,25132
|
10
|
+
ophinode-0.0.1a3.dist-info/METADATA,sha256=lJJMRDEL7x0iRl06U0awGybAT4Ps8ckxwLIUMu-z84o,2409
|
11
|
+
ophinode-0.0.1a3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
12
|
+
ophinode-0.0.1a3.dist-info/licenses/LICENSE,sha256=bPdztUVhioHPZ6OKqBycopwMfGNB5BwVfRHV68sQoVU,1070
|
13
|
+
ophinode-0.0.1a3.dist-info/RECORD,,
|
File without changes
|
File without changes
|