MCPcopy Index your code
hub / github.com/TruthHun/BookStack / htmlPathRule

Function htmlPathRule

static/word2md/mammoth.browser.js:2875–2944  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2873}
2874
2875function htmlPathRule() {
2876 var capture = lop.rules.sequence.capture;
2877 var whitespaceRule = lop.rules.tokenOfType("whitespace");
2878 var freshRule = lop.rules.then(
2879 lop.rules.optional(lop.rules.sequence(
2880 lop.rules.tokenOfType("colon"),
2881 lop.rules.token("identifier", "fresh")
2882 )),
2883 function(option) {
2884 return option.map(function() {
2885 return true;
2886 }).valueOrElse(false);
2887 }
2888 );
2889
2890 var separatorRule = lop.rules.then(
2891 lop.rules.optional(lop.rules.sequence(
2892 lop.rules.tokenOfType("colon"),
2893 lop.rules.token("identifier", "separator"),
2894 lop.rules.tokenOfType("open-paren"),
2895 capture(stringRule),
2896 lop.rules.tokenOfType("close-paren")
2897 ).head()),
2898 function(option) {
2899 return option.valueOrElse("");
2900 }
2901 );
2902
2903 var tagNamesRule = lop.rules.oneOrMoreWithSeparator(
2904 identifierRule,
2905 lop.rules.tokenOfType("choice")
2906 );
2907
2908 var styleElementRule = lop.rules.sequence(
2909 capture(tagNamesRule),
2910 capture(lop.rules.zeroOrMore(classRule)),
2911 capture(freshRule),
2912 capture(separatorRule)
2913 ).map(function(tagName, classNames, fresh, separator) {
2914 var attributes = {};
2915 var options = {};
2916 if (classNames.length > 0) {
2917 attributes["class"] = classNames.join(" ");
2918 }
2919 if (fresh) {
2920 options.fresh = true;
2921 }
2922 if (separator) {
2923 options.separator = separator;
2924 }
2925 return htmlPaths.element(tagName, attributes, options);
2926 });
2927
2928 return lop.rules.firstOf("html path",
2929 lop.rules.then(lop.rules.tokenOfType("bang"), function() {
2930 return htmlPaths.ignore;
2931 }),
2932 lop.rules.then(

Callers 2

createStyleRuleFunction · 0.70
readHtmlPathFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected