mkdocs_table_reader_plugin/plugin.py
def on_page_markdown(self, markdown, page, config, files, **kwargs):
        """
        Replace jinja tag {{ read_csv() }} in markdown with markdown table.

        The page_markdown event is called after the page's markdown is loaded
        from file and can be used to alter the Markdown source text.
        The meta- data has been stripped off and is available as page.meta
        at this point.

        https://www.mkdocs.org/user-guide/plugins/#on_page_markdown

        Args:
            markdown (str): Markdown source text of page as string
            page: mkdocs.nav.Page instance
            config: global configuration object
            site_navigation: global navigation object

        Returns:
            str: Markdown source text of page as string
        """

        mkdocs_dir = os.path.dirname(os.path.abspath(config["config_file_path"]))

        for reader, function in READERS.items():

            # Regex pattern for tags like {{ read_csv(..) }}
            # with a match group to extract the arguments (positional and keywords)
            tag_pattern = re.compile(
                "\{\{ %s\((.+)\) \}\}" % reader, flags=re.IGNORECASE
            )

            matches = re.findall(tag_pattern, markdown)
            for result in matches:

                # Safely parse the arguments
                pd_args, pd_kwargs = parse_argkwarg(result)

                # Make sure the path is relative to "data_path"
                if len(pd_args) > 0:
                    pd_args[0] = os.path.join(self.config.get("data_path"), pd_args[0])
                    file_path = pd_args[0]

                if pd_kwargs.get("filepath_or_buffer"):
                    file_path = pd_kwargs["filepath_or_buffer"]
                    file_path = os.path.join(self.config.get("data_path"), file_path)
                    pd_kwargs["filepath_or_buffer"] = file_path

                # Insert markdown table
                # By replacing first occurance of the regex pattern
                with cd(mkdocs_dir):
                    if not os.path.exists(file_path):
                        raise FileNotFoundError(
                            "[table-reader-plugin]: File does not exist: %s" % file_path
                        )

                    markdown_table = function(*pd_args, **pd_kwargs)

                markdown = tag_pattern.sub(markdown_table, markdown, count=1)

        return markdown

        Replace jinja tag {{ read_csv() }} in markdown with markdown table.

        The page_markdown event is called after the page's markdown is loaded
        from file and can be used to alter the Markdown source text.
        The meta- data has been stripped off and is available as page.meta
        at this point.

        https://www.mkdocs.org/user-guide/plugins/#on_page_markdown

        Args:
            markdown (str): Markdown source text of page as string
            page: mkdocs.nav.Page instance
            config: global configuration object
            site_navigation: global navigation object

        Returns:
            str: Markdown source text of page as string
        
Replace jinja tag {{ read_csv() }} in markdown with markdown table.
The page_markdown event is called after the page's markdown is loaded
from file and can be used to alter the Markdown source text.
The meta- data has been stripped off and is available as page.meta
at this point.


Replace jinja tag {{ read_csv () }} in markdown with markdown table . The page_markdown event is called after the page ' s markdown is loaded from file and can be used to alter the Markdown source text . The meta - data has been stripped off and is available as page . meta at this point .
def on_page_markdown(self, markdown, page, config, files, **kwargs):
        mkdocs_dir = os.path.dirname(os.path.abspath(config["config_file_path"]))
        for reader, function in READERS.items():
            tag_pattern = re.compile(
                "\{\{ %s\((.+)\) \}\}" % reader, flags=re.IGNORECASE
            )
            matches = re.findall(tag_pattern, markdown)
            for result in matches:
                pd_args, pd_kwargs = parse_argkwarg(result)
                if len(pd_args) > 0:
                    pd_args[0] = os.path.join(self.config.get("data_path"), pd_args[0])
                    file_path = pd_args[0]
                if pd_kwargs.get("filepath_or_buffer"):
                    file_path = pd_kwargs["filepath_or_buffer"]
                    file_path = os.path.join(self.config.get("data_path"), file_path)
                    pd_kwargs["filepath_or_buffer"] = file_path
                with cd(mkdocs_dir):
                    if not os.path.exists(file_path):
                        raise FileNotFoundError(
                            "[table-reader-plugin]: File does not exist: %s" % file_path
                        )
                    markdown_table = function(*pd_args, **pd_kwargs)
                markdown = tag_pattern.sub(markdown_table, markdown, count=1)
        return markdown
def on_page_markdown ( self , markdown , page , config , files , ** kwargs ) : mkdocs_dir = os . path . dirname ( os . path . abspath ( config [ "config_file_path" ] ) ) for reader , function in READERS . items ( ) : tag_pattern = re . compile ( "\{\{ %s\((.+)\) \}\}" % reader , flags = re . IGNORECASE ) matches = re . findall ( tag_pattern , markdown ) for result in matches : pd_args , pd_kwargs = parse_argkwarg ( result ) if len ( pd_args ) > 0 : pd_args [ 0 ] = os . path . join ( self . config . get ( "data_path" ) , pd_args [ 0 ] ) file_path = pd_args [ 0 ] if pd_kwargs . get ( "filepath_or_buffer" ) : file_path = pd_kwargs [ "filepath_or_buffer" ] file_path = os . path . join ( self . config . get ( "data_path" ) , file_path ) pd_kwargs [ "filepath_or_buffer" ] = file_path with cd ( mkdocs_dir ) : if not os . path . exists ( file_path ) : raise FileNotFoundError ( "[table-reader-plugin]: File does not exist: %s" % file_path ) markdown_table = function ( * pd_args , ** pd_kwargs ) markdown = tag_pattern . sub ( markdown_table , markdown , count = 1 ) return markdown
Replace jinja tag {{ read_csv() }} in markdown with markdown table.
Replace jinja tag {{ read_csv () }} in markdown with markdown table .
"""
        Replace jinja tag {{ read_csv() }} in markdown with markdown table.

        The page_markdown event is called after the page's markdown is loaded
        from file and can be used to alter the Markdown source text.
        The meta- data has been stripped off and is available as page.meta
        at this point.

        https://www.mkdocs.org/user-guide/plugins/#on_page_markdown

        Args:
            markdown (str): Markdown source text of page as string
            page: mkdocs.nav.Page instance
            config: global configuration object
            site_navigation: global navigation object

        Returns:
            str: Markdown source text of page as string
        """ # Regex pattern for tags like {{ read_csv(..) }} # with a match group to extract the arguments (positional and keywords) # Safely parse the arguments # Make sure the path is relative to "data_path" # Insert markdown table # By replacing first occurance of the regex pattern
Markdown source text of page as string
Markdown source text of page as string
str
self
markdown
Markdown source text of page as string
Markdown source text of page as string
page
None
config
global configuration object
global configuration object
files
site_navigation
global navigation object
global navigation object