PATH: //opt/alt/python311/share/doc/alt-python311-pyparsing-doc/examples
FILE_BARU
CREATE
FOLDER_BARU
MKDIR
UPLOAD_FILE
GO
[ .. KEMBALI ]
📄 0README.html
↓
X
📄 AcManForm.dfm
↓
X
📄 LAparser.py
↓
X
📄 Setup.ini
↓
X
📄 SimpleCalc.py
↓
X
📄 SingleForm.dfm
↓
X
📄 TAP.py
↓
X
📄 __init__.py
↓
X
📁 __pycache__/
X
📄 adventureEngine.py
↓
X
📄 antlr_grammar.py
↓
X
📄 antlr_grammar_tests.py
↓
X
📄 apicheck.py
↓
X
📄 bigquery_view_parser.py
↓
X
📄 booleansearchparser.py
↓
X
📄 btpyparse.py
↓
X
📄 builtin_parse_action_demo.py
↓
X
📄 cLibHeader.py
↓
X
📄 chemicalFormulas.py
↓
X
📄 commasep.py
↓
X
📄 configParse.py
↓
X
📄 cpp_enum_parser.py
↓
X
📄 cuneiform_python.py
↓
X
📄 datetimeParseActions.py
↓
X
📄 decaf_parser.py
↓
X
📄 delta_time.py
↓
X
📄 dfmparse.py
↓
X
📄 dhcpd_leases_parser.py
↓
X
📄 dictExample.py
↓
X
📄 dictExample2.py
↓
X
📄 ebnf.py
↓
X
📄 ebnftest.py
↓
X
📄 eval_arith.py
↓
X
📄 excelExpr.py
↓
X
📄 fourFn.py
↓
X
📄 gen_ctypes.py
↓
X
📄 getNTPserversNew.py
↓
X
📄 greeting.py
↓
X
📄 greetingInGreek.py
↓
X
📄 greetingInKorean.py
↓
X
📄 groupUsingListAllMatches.py
↓
X
📄 holaMundo.py
↓
X
📄 htmlStripper.py
↓
X
📄 htmlTableParser.py
↓
X
📄 httpServerLogParser.py
↓
X
📄 idlParse.py
↓
X
📄 include_preprocessor.py
↓
X
📄 indentedGrammarExample.py
↓
X
📄 indented_block_example.py
↓
X
📄 invRegex.py
↓
X
📄 javascript_grammar.g
↓
X
📄 jsonParser.py
↓
X
📄 left_recursion.py
↓
X
📄 linenoExample.py
↓
X
📄 listAllMatches.py
↓
X
📄 lua_parser.py
↓
X
📄 lucene_grammar.py
↓
X
📄 macroExpander.py
↓
X
📄 make_diagram.py
↓
X
📄 matchPreviousDemo.py
↓
X
📄 mozilla.ics
↓
X
📄 mozillaCalendarParser.py
↓
X
📄 nested.py
↓
X
📄 nested_markup.py
↓
X
📄 number_words.py
↓
X
📄 numerics.py
↓
X
📄 oc.py
↓
X
📄 one_to_ninety_nine.py
↓
X
📄 parsePythonValue.py
↓
X
📄 parseResultsSumExample.py
↓
X
📄 parseTabularData.py
↓
X
📄 partial_gene_match.py
↓
X
📄 pgn.py
↓
X
📄 position.py
↓
X
📄 protobuf_parser.py
↓
X
📄 pymicko.py
↓
X
📄 pythonGrammarParser.py
↓
X
📄 railroad_diagram_demo.py
↓
X
📄 rangeCheck.py
↓
X
📄 readJson.py
↓
X
📄 removeLineBreaks.py
↓
X
📄 romanNumerals.py
↓
X
📄 rosettacode.py
↓
X
📄 scanExamples.py
↓
X
📄 searchParserAppDemo.py
↓
X
📄 searchparser.py
↓
X
📄 select_parser.py
↓
X
📄 sexpParser.py
↓
X
📄 shapes.py
↓
X
📄 simpleArith.py
↓
X
📄 simpleBool.py
↓
X
📄 simpleSQL.py
↓
X
📄 simpleWiki.py
↓
X
📄 snmp_api.h
↓
X
📄 sparser.py
↓
X
📄 sql2dot.py
↓
X
📄 stackish.py
↓
X
📁 statemachine/
X
📄 test_bibparse.py
↓
X
📄 unicode_denormalizer.py
↓
X
📄 urlExtractor.py
↓
X
📄 urlExtractorNew.py
↓
X
📁 verilog/
X
📄 verilogParse.py
↓
X
📄 withAttribute.py
↓
X
📄 wordsToNum.py
↓
X
SAVING...
BERHASIL DIUBAH!
EDITING: nested_markup.py
# # nested_markup.py # # Example markup parser to recursively transform nested markup directives. # # Copyright 2019, Paul McGuire # import pyparsing as pp wiki_markup = pp.Forward() # a method that will construct and return a parse action that will # do the proper wrapping in opening and closing HTML, and recursively call # wiki_markup.transformString on the markup body text def convert_markup_to_html(opening, closing): def conversionParseAction(s, l, t): return opening + wiki_markup.transformString(t[1][1:-1]) + closing return conversionParseAction # use a nestedExpr with originalTextFor to parse nested braces, but return the # parsed text as a single string containing the outermost nested braces instead # of a nested list of parsed tokens markup_body = pp.originalTextFor(pp.nestedExpr("{", "}")) italicized = ("ital" + markup_body).setParseAction( convert_markup_to_html("<I>", "</I>") ) bolded = ("bold" + markup_body).setParseAction(convert_markup_to_html("<B>", "</B>")) # another markup and parse action to parse links - again using transform string # to recursively parse any markup in the link text def convert_link_to_html(s, l, t): link_text, url = t._skipped t["link_text"] = wiki_markup.transformString(link_text) t["url"] = url return '<A href="{url}">{link_text}</A>'.format_map(t) urlRef = (pp.Keyword("link") + "{" + ... + "->" + ... + "}").setParseAction( convert_link_to_html ) # now inject all the markup bits as possible markup expressions wiki_markup <<= urlRef | italicized | bolded # try it out! wiki_input = """ Here is a simple Wiki input: ital{This is in italics}. bold{This is in bold}! bold{This is in ital{bold italics}! But this is just bold.} Here's a URL to link{Pyparsing's bold{Wiki Page}!->https://github.com/pyparsing/pyparsing/wiki} """ print(wiki_markup.transformString(wiki_input))
SIMPAN PERUBAHAN