@Override public void accept(final String s) { myTranslationStore.get(UNWRAPPED_AUTO_LINKS_MAP).add(s); } });
/** * Add extension(s) to the extension list * * @param options mutable options holding existing extensions * @param extensions extension to add * @return mutable options */ public static MutableDataHolder addExtensions(MutableDataHolder options, Extension... extensions) { Iterable<Extension> extensionIterable = options.get(Parser.EXTENSIONS); ArrayList<Extension> extensionList = new ArrayList<Extension>(); extensionList.addAll(Arrays.asList(extensions)); for (Extension extension : extensionIterable) { extensionList.add(extension); } options.set(Parser.EXTENSIONS, extensionList); return options; }
public static String getEncodedIdAttribute(String category, String categoryId, NodeFormatterContext context, MarkdownWriter markdown) { Map<String, String> attributeTranslationMap = context.getTranslationStore().get(ATTRIBUTE_TRANSLATION_MAP); Map<String, String> attributeTranslatedMap = context.getTranslationStore().get(ATTRIBUTE_TRANSLATED_MAP); return getEncodedIdAttribute(category, categoryId, context, markdown, attributeTranslationMap, attributeTranslatedMap); }
/** * Remove extension(s) of given class from the extension list * * @param options mutable options holding existing extensions * @param extensions extension classes to remove * @return mutable options */ public static MutableDataHolder removeExtensions(MutableDataHolder options, Class... extensions) { Iterable<Extension> extensionIterable = options.get(Parser.EXTENSIONS); HashSet<Extension> extensionList = new HashSet<Extension>(); for (Extension extension : extensionIterable) { boolean keep = true; for (Class clazz : extensions) { if (clazz.isInstance(extension)) { keep = false; break; } } if (keep) { extensionList.add(extension); } } options.set(Parser.EXTENSIONS, extensionList); return options; } }
@Override public boolean canContain(ParserState state, BlockParser blockParser, Block block) { // Issue 66, fenced code can only be contained in GitHub Doc mode if it is indented more than list item if (block instanceof FencedCodeBlock) { // see if it indented more than our marker if (state.getProperties().get(PARSER_EMULATION_PROFILE) == GITHUB_DOC) { // Issue #66, if we are in a list item and our indent == list indent then we interrupt the list FencedCodeBlockParser parser = (FencedCodeBlockParser)blockParser; return myListData.markerIndent < parser.getFenceMarkerIndent(); } } return true; }
@Override public void closeBlock(ParserState state) { block.setCharsFromContent(); if (!state.getProperties().get(Parser.BLANK_LINES_IN_AST)) { removeBlankLines(); } }
@Override public void closeBlock(ParserState state) { if (state.getProperties().get(TRACK_DOCUMENT_LINES)) { document.setContent(state.getLineSegments()); } } }
@Override public void closeBlock(ParserState state) { block.setCharsFromContent(); if (!state.getProperties().get(Parser.BLANK_LINES_IN_AST)) { removeBlankLines(); } }
@Override public void closeBlock(ParserState state) { // add it to the map AbbreviationRepository abbreviationMap = state.getProperties().get(AbbreviationExtension.ABBREVIATIONS); abbreviationMap.put(abbreviationMap.normalizeKey(block.getText()).toString(), block); }
private static String getEncodedIdAttribute(String category, String categoryId, NodeFormatterContext context, MarkdownWriter markdown, Map<String, String> attributeTranslationMap, Map<String, String> attributeTranslatedMap) { String encodedCategory = category; String encodedId = categoryId; int placeholderId = context.getTranslationStore().get(ATTRIBUTE_TRANSLATION_ID);
@Override public void renderDocument(final NodeFormatterContext context, final MarkdownWriter markdown, final Document document, final FormattingPhase phase) { // reset storage for attribute keys and attributes map if (context.isTransformingText()) { if (context.getRenderPurpose() == TRANSLATION_SPANS) { context.getTranslationStore().set(ATTRIBUTE_TRANSLATION_MAP, new HashMap<String, String>()); context.getTranslationStore().set(ATTRIBUTE_TRANSLATED_MAP, new HashMap<String, String>()); context.getTranslationStore().set(ATTRIBUTE_ORIGINAL_ID_MAP, new HashMap<String, String>()); } context.getTranslationStore().set(ATTRIBUTE_TRANSLATION_ID, 0); attributeOriginalId = 0; attributeTranslationMap = context.getTranslationStore().get(ATTRIBUTE_TRANSLATION_MAP); attributeTranslatedMap = context.getTranslationStore().get(ATTRIBUTE_TRANSLATED_MAP); attributeOriginalIdMap = context.getTranslationStore().get(ATTRIBUTE_ORIGINAL_ID_MAP); } }
@Override public void closeBlock(ParserState state) { block.setContent(content); block.setCharsFromContent(); content = null; // set the footnote from closingMarker to end block.setCharsFromContent(); // add it to the map MacroDefinitionRepository macrosRepository = state.getProperties().get(MacrosExtension.MACRO_DEFINITIONS); macrosRepository.put(macrosRepository.normalizeKey(block.getName()), block); }
@Override public void closeBlock(ParserState state) { finalizeListTight(state); if (state.getProperties().get(BLANK_LINES_IN_AST)) { // need to transfer trailing blank line nodes from last item to parent list ListBlock block = getBlock(); Node child = block.getFirstChildAnyNot(BlankLine.class); while (child instanceof ListItem) { // transfer its trailing blank lines to us child.moveTrailingBlankLines(); child = child.getNextAnyNot(BlankLine.class); } } myBlock.setCharsFromContentOnly(); }
@Override public void preProcess(ParserState state, Block block) { Boolean blankLinesInAST = state.getProperties().get(BLANK_LINES_IN_AST); if (block instanceof DefinitionList) { // need to propagate loose/tight final DefinitionList definitionList = (DefinitionList) block; boolean isTight = definitionList.isTight(); if (options.autoLoose && isTight) { for (Node child : definitionList.getChildren()) { if (child instanceof DefinitionItem) { if (((DefinitionItem) child).isLoose()) { isTight = false; if (!blankLinesInAST) break; } if (blankLinesInAST) { // transfer its trailing blank lines to uppermost level child.moveTrailingBlankLines(); } } } definitionList.setTight(isTight); } if (blankLinesInAST) { definitionList.moveTrailingBlankLines(); } } }
context.getTranslationStore().set(myReferenceMapKey, new HashMap<String, String>()); referenceTranslationMap = context.getTranslationStore().get(myReferenceMapKey);
@Override public void closeBlock(ParserState state) { // set the footnote from closingMarker to end block.setCharsFromContent(); block.setFootnote(block.getChars().subSequence(block.getClosingMarker().getEndOffset() - block.getChars().getStartOffset()).trimStart()); // add it to the map FootnoteRepository footnoteMap = state.getProperties().get(FootnoteExtension.FOOTNOTES); footnoteMap.put(footnoteMap.normalizeKey(block.getText()), block); content = null; }
@Override public void closeBlock(ParserState state) { block.setCharsFromContent(); if (!state.getProperties().get(Parser.BLANK_LINES_IN_AST)) { removeBlankLines(); } }
@Override public void closeBlock(ParserState state) { block.setCharsFromContent(); if (!state.getProperties().get(Parser.BLANK_LINES_IN_AST)) { removeBlankLines(); } }
@Override public void closeBlock(ParserState state) { // set the footnote from closingMarker to end block.setCharsFromContent(); block.setFootnote(block.getChars().subSequence(block.getClosingMarker().getEndOffset() - block.getChars().getStartOffset()).trimStart()); // add it to the map FootnoteRepository footnoteMap = state.getProperties().get(FootnoteExtension.FOOTNOTES); footnoteMap.put(footnoteMap.normalizeKey(block.getText()), block); content = null; }