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

Function documentMatcherRule

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

Source from the content-addressed store, hash-verified

2713}
2714
2715function documentMatcherRule() {
2716 var sequence = lop.rules.sequence;
2717
2718 var identifierToConstant = function(identifier, constant) {
2719 return lop.rules.then(
2720 lop.rules.token("identifier", identifier),
2721 function() {
2722 return constant;
2723 }
2724 );
2725 };
2726
2727 var paragraphRule = identifierToConstant("p", documentMatchers.paragraph);
2728 var runRule = identifierToConstant("r", documentMatchers.run);
2729
2730 var elementTypeRule = lop.rules.firstOf("p or r or table",
2731 paragraphRule,
2732 runRule
2733 );
2734
2735 var styleIdRule = lop.rules.then(
2736 classRule,
2737 function(styleId) {
2738 return {styleId: styleId};
2739 }
2740 );
2741
2742 var styleNameMatcherRule = lop.rules.firstOf("style name matcher",
2743 lop.rules.then(
2744 lop.rules.sequence(
2745 lop.rules.tokenOfType("equals"),
2746 lop.rules.sequence.cut(),
2747 lop.rules.sequence.capture(stringRule)
2748 ).head(),
2749 function(styleName) {
2750 return {styleName: documentMatchers.equalTo(styleName)};
2751 }
2752 ),
2753 lop.rules.then(
2754 lop.rules.sequence(
2755 lop.rules.tokenOfType("startsWith"),
2756 lop.rules.sequence.cut(),
2757 lop.rules.sequence.capture(stringRule)
2758 ).head(),
2759 function(styleName) {
2760 return {styleName: documentMatchers.startsWith(styleName)};
2761 }
2762 )
2763 );
2764
2765 var styleNameRule = lop.rules.sequence(
2766 lop.rules.tokenOfType("open-square-bracket"),
2767 lop.rules.sequence.cut(),
2768 lop.rules.token("identifier", "style-name"),
2769 lop.rules.sequence.capture(styleNameMatcherRule),
2770 lop.rules.tokenOfType("close-square-bracket")
2771 ).head();
2772

Callers 2

createStyleRuleFunction · 0.70
readDocumentMatcherFunction · 0.70

Calls 2

identifierToConstantFunction · 0.70

Tested by

no test coverage detected