Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: iamjackg/md2cf
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: jhogstrom/md2cf
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 1 commit
  • 3 files changed
  • 1 contributor

Commits on Aug 30, 2023

  1. Added replacement facility for page content.

    By using either command line replacement pairs or specifying a file
    with json defintions of replacements an arbitrary regexp ("pattern")
    can be detected and replaced with another string, including expanding
    captured groups in the pattern.
    
    The replacement phase is taking place just before upsert, so all other
    textual manipulations are done by that time.
    
    Replacements happen in a deterministic sequence. There are ample
    opportunities to get unexpected (but logically consistent) results
    by inadvertently result of a previous replacement.
    
    Format of json file:
    ```
    {
        "environment": [
            {
                "import": "<module name>",
                "path": "<source file>"
            }
        ],
        "replacements":[
            {
                "name": "<name - optional>",
                "pattern": "<regexp>",
                "new_value": "<string with optional group expansions>"
                "evaluate": <true|false - optional>
            },
        ]
    }
    ```
    The `environment` block is optional and used for very dynamic
    replacements. By specifying a python source file, it will be
    dynamically imported at run time. The `new_value` field can then specify
    a `<module>.<func>` that returns a string value. As an example, the
    following adds a replacement of "TODAY" to an iso-formatted datetime.
    
    ```
    {
        "environment": [
            {
                "import": "funcs",
                "path": "funcs.py"
            }
        ],
        "replacements":[
            {
                "name": "Todays date",
                "pattern": "TODAY",
                "new_value": "funcs.today"
                "evaluate": true
            },
        ]
    }
    ```
    
    Funcs.py:
    ```
    import datetime
    
    def today(term):
        return datetime.datetime.now().isoformat()
    ```
    
    The parameter `term` is a Match object as per using
    https://docs.python.org/3/library/re.html#re.subn.
    jhogstrom committed Aug 30, 2023
    Configuration menu
    Copy the full SHA
    6f5f63a View commit details
    Browse the repository at this point in the history
Loading