22"""
33HTML
44
5- Basic implementation for a HTML importer.
5+ HTML importer.
66"""
77
88
1515from mathics .core .builtin import Builtin , MessageException
1616from mathics .core .convert .expression import to_expression , to_mathics_list
1717from mathics .core .convert .python import from_python
18+ from mathics .core .evaluation import Evaluation
1819from mathics .core .expression import Expression
1920from mathics .core .list import ListExpression
2021from mathics .core .symbols import Symbol
@@ -126,7 +127,7 @@ class _TagImport(_HTMLBuiltin):
126127 def _import (self , tree ):
127128 raise NotImplementedError
128129
129- def eval (self , text , evaluation ):
130+ def eval (self , text : String , evaluation : Evaluation ):
130131 """%(name)s[text_String]"""
131132 tree = parse_html (parse_html_file , text , evaluation )
132133 if isinstance (tree , Symbol ): # $Failed?
@@ -135,6 +136,12 @@ def eval(self, text, evaluation):
135136 to_expression (SymbolRule , self .tag_name , self ._import (tree ))
136137 )
137138
139+ def eval_with_element (self , text , element , evaluation : Evaluation ):
140+ """%(name)s[text_String, element_]"""
141+ # FIXME: right now we aren't using element, and should use this to more
142+ # efficiently extract part of the XML file that we want.
143+ return self .eval (text , evaluation )
144+
138145
139146class _Get (_HTMLBuiltin ):
140147 context = "HTML`Parser`"
@@ -401,7 +408,7 @@ class SourceImport(_HTMLBuiltin):
401408
402409 summary_text = "import source code from a HTML file"
403410
404- def eval (self , text , evaluation ):
411+ def eval (self , text , evaluation : Evaluation ):
405412 """%(name)s[text_String]"""
406413
407414 def source (filename ):
@@ -412,6 +419,12 @@ def source(filename):
412419
413420 return parse_html (source , text , evaluation )
414421
422+ def eval_with_element (self , text , element , evaluation : Evaluation ):
423+ """%(name)s[text_String, element_]"""
424+ # FIXME: right now we aren't using element, and should use this to more
425+ # efficiently extract part of the XML file that we want.
426+ return self .eval (text , evaluation )
427+
415428
416429class TitleImport (_TagImport ):
417430 """
@@ -437,7 +450,7 @@ def _import(self, tree):
437450
438451class XMLObjectImport (_HTMLBuiltin ):
439452 """
440- ## <url>:native internal: </url>
453+ <url>:WMA link:https://reference.wolfram.com/language/ref/XMLObject.html </url>
441454
442455 <dl>
443456 <dt>'HTML`XMLObjectImport["filename"]'
@@ -450,7 +463,13 @@ class XMLObjectImport(_HTMLBuiltin):
450463
451464 summary_text = "import XML objects from a HTML file"
452465
453- def eval (self , text , evaluation ):
466+ def eval (self , text , evaluation : Evaluation ):
454467 """%(name)s[text_String]"""
455468 xml = to_expression ("HTML`Parser`HTMLGet" , text ).evaluate (evaluation )
456469 return ListExpression (Expression (SymbolRule , String ("XMLObject" ), xml ))
470+
471+ def eval_with_element (self , text , element , evaluation : Evaluation ):
472+ """%(name)s[text_String, element_]"""
473+ # FIXME: right now we aren't using element, and should use this to more
474+ # efficiently extract part of the HTML file that we want.
475+ return self .eval (text , evaluation )
0 commit comments