Repository: timvink/mkdocs-table-reader-plugin

Issue:
Conflict with mkdocs-markdownextradata-plugin
When using both the `mkdocs-markdownextradata-plugin` and this `mkdocs-table-reader-plugin`, there is a conflict when using the `{{ read_csv("table.csv") }}` (and other) placeholders from `mkdocs-table-reader-plugin` which are tried to be interpreted as `mkdocs-markdownextradata-plugin` placeholders.

When running `mkdocs serve` on docs containing `{{ read_csv("table.csv") }}`, then an error occurs:
`jinja2.exceptions.UndefinedError: 'read_csv' is undefined`.
This seems to be caused by the `mkdocs-table-reader-plugin` placeholders to be trying to be interpreted as `mkdocs-markdownextradata-plugin` placeholders, because both rely on the same `{{ placeholder }}` pattern within the markdown docs.

A temporary solution is to specify a different placeholder pattern for `mkdocs-markdownextradata-plugin` in the `mkdocs.yml`:
```
plugins:
    - search
    - markdownextradata:
        jinja_options:
            variable_start_string: "{{{"
            variable_end_string: "}}}"
```

Discussion:

Patch:
diff --git a/mkdocs_table_reader_plugin/plugin.py b/mkdocs_table_reader_plugin/plugin.py
index 3e9d4c2..9912e3f 100644
--- a/mkdocs_table_reader_plugin/plugin.py
+++ b/mkdocs_table_reader_plugin/plugin.py
@@ -81,9 +81,10 @@ class TableReaderPlugin(BasePlugin):
 
         plugins = [p for p in config.get("plugins")]
 
-        if "macros" in plugins:
-            if plugins.index("table-reader") > plugins.index("macros"):
-                raise ConfigurationError("[table-reader]: Incompatible plugin order: Define 'table-reader' before 'macros' in your mkdocs.yml.")
+        for post_load_plugin in ["macros", "markdownextradata"]:
+            if post_load_plugin in plugins:
+                if plugins.index("table-reader") > plugins.index(post_load_plugin):
+                    raise ConfigurationError(f"[table-reader]: Incompatible plugin order: Define 'table-reader' before '{post_load_plugin}' in your mkdocs.yml.")
 
 
     def on_page_markdown(self, markdown, page, config, files, **kwargs):
@@ -115,7 +116,7 @@ class TableReaderPlugin(BasePlugin):
             # match group 0: to extract any leading whitespace 
             # match group 1: to extract the arguments (positional and keywords)
             tag_pattern = re.compile(
-                "( *)\{\{ %s\((.+)\) \}\}" % reader, flags=re.IGNORECASE
+                "( *)\{\{\s+%s\((.+)\)\s+\}\}" % reader, flags=re.IGNORECASE
             )
 
             matches = re.findall(tag_pattern, markdown)
diff --git a/setup.py b/setup.py
index 272eee4..2a5d010 100644
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
 
 setup(
     name="mkdocs-table-reader-plugin",
-    version="0.6",
+    version="0.6.1",
     description="MkDocs plugin to directly insert tables from files into markdown.",
     long_description=long_description,
     long_description_content_type="text/markdown",


Test patch:
diff --git a/tests/fixtures/basic_setup/docs/bad_tags.md b/tests/fixtures/basic_setup/docs/bad_tags.md
index 47f81e7..00b4590 100644
--- a/tests/fixtures/basic_setup/docs/bad_tags.md
+++ b/tests/fixtures/basic_setup/docs/bad_tags.md
@@ -8,9 +8,6 @@ some badly formatted tags:
 
 {{ read_csv() }}
 
-## Strange and wrong characters
-
-{{ read\_csv('path') }}
 
 ## No proper spaces
 
diff --git a/tests/fixtures/basic_setup/mkdocs.yml b/tests/fixtures/basic_setup/mkdocs.yml
index a7c596b..a8cedf8 100644
--- a/tests/fixtures/basic_setup/mkdocs.yml
+++ b/tests/fixtures/basic_setup/mkdocs.yml
@@ -1,5 +1,5 @@
 site_name: test git_table_reader site
-use_directory_urls: true
+use_directory_urls: false
 
 plugins:
     - search
diff --git a/tests/fixtures/datapathproject/mkdocs.yml b/tests/fixtures/datapathproject/mkdocs.yml
index 9ba92b9..bf25f75 100644
--- a/tests/fixtures/datapathproject/mkdocs.yml
+++ b/tests/fixtures/datapathproject/mkdocs.yml
@@ -1,5 +1,5 @@
 site_name: test git_table_reader site
-use_directory_urls: true
+use_directory_urls: false
 
 plugins:
     - search
diff --git a/tests/fixtures/datapathproject/mkdocs_trailingslash.yml b/tests/fixtures/datapathproject/mkdocs_trailingslash.yml
index 32c22f5..ee11250 100644
--- a/tests/fixtures/datapathproject/mkdocs_trailingslash.yml
+++ b/tests/fixtures/datapathproject/mkdocs_trailingslash.yml
@@ -1,5 +1,5 @@
 site_name: test git_table_reader site
-use_directory_urls: true
+use_directory_urls: false
 
 plugins:
     - search
diff --git a/tests/fixtures/markdownextradata/mkdocs_w_markdownextradata.yml b/tests/fixtures/markdownextradata/mkdocs_w_markdownextradata.yml
new file mode 100644
index 0000000..3485308
--- /dev/null
+++ b/tests/fixtures/markdownextradata/mkdocs_w_markdownextradata.yml
@@ -0,0 +1,13 @@
+site_name: test git_table_reader site
+use_directory_urls: true
+
+plugins:
+    - search
+    - table-reader
+    - markdownextradata
+
+extra:
+    customer:
+        name: Your name here
+        web: www.example.com
+        salt: salt.example.com
\ No newline at end of file
diff --git a/tests/fixtures/markdownextradata/mkdocs_w_markdownextradata_wrong_order.yml b/tests/fixtures/markdownextradata/mkdocs_w_markdownextradata_wrong_order.yml
new file mode 100644
index 0000000..812a329
--- /dev/null
+++ b/tests/fixtures/markdownextradata/mkdocs_w_markdownextradata_wrong_order.yml
@@ -0,0 +1,13 @@
+site_name: test git_table_reader site
+use_directory_urls: true
+
+plugins:
+    - search
+    - markdownextradata
+    - table-reader
+
+extra:
+    customer:
+        name: Your name here
+        web: www.example.com
+        salt: salt.example.com
\ No newline at end of file
diff --git a/tests/test_build.py b/tests/test_build.py
index 7d2442a..08dab3f 100644
--- a/tests/test_build.py
+++ b/tests/test_build.py
@@ -178,6 +178,27 @@ def test_compatibility_markdownextradata(tmp_path):
     # Make sure the extradata 'web' is inserted
     assert re.search(r"www.example.com", contents)
 
+    tmp_proj = setup_clean_mkdocs_folder(
+        "tests/fixtures/markdownextradata/mkdocs_w_markdownextradata_wrong_order.yml", tmp_path
+    )
+
+    result = build_docs_setup(tmp_proj)
+    assert result.exit_code == 1, "'mkdocs build' command should have failed"
+
+    # Make sure correct error is raised
+    assert (
+        "[table-reader]: Incompatible plugin order:"
+        in result.output
+    )
+
+    # With correct order, no error
+    tmp_proj = setup_clean_mkdocs_folder(
+        "tests/fixtures/markdownextradata/mkdocs_w_markdownextradata.yml", tmp_path
+    )
+
+    result = build_docs_setup(tmp_proj)
+    assert result.exit_code == 0, "'mkdocs build' command should have succeeded"
+
 
 def test_datapath_1(tmp_path):