com.groupdocs.parser

Interfaces

Classes

Exceptions

com.groupdocs.parser

Class MarkdownTextExtractor

  • All Implemented Interfaces:
    IHighlightExtractor, IRegexSearchable, ISearchable, IStructuredExtractor, AutoCloseable


    public final class MarkdownTextExtractor
    extends TextExtractor
    implements IStructuredExtractor, ISearchable, IRegexSearchable, IHighlightExtractor

    Provides the text extractor for Markdown (.md) documents.

    Extracts a line of characters from a document:

     // Create a text extractor for Markdown documents
     TextExtractor extractor = new MarkdownTextExtractor(stream);
     // Extract a line of the text
     String line = extractor.extractLine();
     // If the line is null, then the end of the file is reached
     while (line != null) {
         // Print a line to the console
         System.out.println(line);
         // Extract another line
         line = extractor.extractLine();
     }
      

    Extracts all characters from a document:

     // Create a text extractor for Markdown documents
     TextExtractor extractor = new MarkdownTextExtractor(stream);
     // Extract a text
     System.out.println(extractor.extractAll());
      
    • Constructor Detail

      • MarkdownTextExtractor

        public MarkdownTextExtractor(String fileName)

        Initializes a new instance of the MarkdownTextExtractor class.

        Parameters:
        fileName - The path to the file.
      • MarkdownTextExtractor

        public MarkdownTextExtractor(InputStream stream)

        Initializes a new instance of the MarkdownTextExtractor class.

        Parameters:
        stream - The stream of the document.
    • Method Detail

      • search

        public void search(SearchOptions options,
                  ISearchHandler handler,
                  List<String> keywords)

        Searches the keywords.

        Specified by:
        search in interface ISearchable
        Parameters:
        options - Options for searching.
        handler - An instance of the search handler.
        keywords - A collection of words to search.
      • search

        public void search(SearchOptions options,
                  ISearchHandler handler,
                  ISearchEngine searchEngine,
                  List<String> keywords)

        Searches the keywords.

        Specified by:
        search in interface ISearchable
        Parameters:
        options - Options for searching.
        handler - An instance of the search handler.
        searchEngine - An instance of the search engine.
        keywords - A collection of words to search.
      • extractHighlights

        public List<String> extractHighlights(HighlightOptions... highlightOptions)

        Extracts highlights.

        Specified by:
        extractHighlights in interface IHighlightExtractor
        Parameters:
        highlightOptions - A collection of HighlightOptions.
        Returns:
        A collection of strings that represent highlights. If no highlight is found, a collection is empty.
      • reset

        public void reset()

        Resets the current document.


        Resets the cursor's position. ExtractLine method will return the first line of the document.

        Overrides:
        reset in class TextExtractor
      • prepareLine

        protected String prepareLine()

        Returns a line of the text.

        Specified by:
        prepareLine in class TextExtractor
        Returns:
        A string that represents a line of the text, or null if all characters have been read.
      • dispose

        protected void dispose(boolean disposing)

        Releases the unmanaged resources used by the extractor.

        Overrides:
        dispose in class TextExtractor
        Parameters:
        disposing - A boolean true if invoked from Dispose; otherwise, false.