8000 Code Annotations and Terraform · Issue #3696 · squidfunk/mkdocs-material · GitHub
[go: up one dir, main page]

Skip to content

Code Annotations and Terraform #3696

@azbpa

Description

@azbpa

Contribution guidelines

I've found a bug and checked that ...

  • ... the problem doesn't occur with the mkdocs or readthedocs themes
  • ... the problem persists when all overrides are removed, i.e. custom_dir, extra_javascript and extra_css
  • ... the documentation does not mention anything about my problem
  • ... there are no open or closed issues that are related to my problem

Description

I tried to use Code Annotations with Terraform syntax highlighting as the following:

index.md

# Problem 1

``` terraform
terraform { # (1)
    required_version = ">= 1.1.0" 
} 

provider "azurerm" { # (2)
    features {} 
}
```

1.  Hello World 1
2.  Hello World 2

# Problem 2

``` terraform
terraform { # (1)
    required_version = ">= 1.1.0" 
} 

provider "azurerm" { 
    features {} 
}

# (2)
module "hello_world" {
    source "../.."
    foo = "bar"
}
```

1.  Hello World 1
2.  Hello World 2

Expected behaviour

Code Annotations should render correctly for both code blocks.

Actual behaviour

HTLM output looks like this:
image

Problem 1
It looks like # (2) is not treated as a comment. At least it isn't highlighted the same way as the other comment.

Problem 2
Browser is throwing the following exception:

index.ts:77 Uncaught TypeError: Cannot read properties of null (reading 'textContent')
    at cs (index.ts:77:43)
    at Zo (index.ts:120:24)
    at index.ts:193:30
    at e._subscribe (defer.ts:55:15)
    at e._trySubscribe (Observable.ts:245:19)
    at Observable.ts:235:18
    at nt (errorContext.ts:29:5)
    at e.subscribe (Observable.ts:221:5)
    at switchMap.ts:109:49
    at t.s._next (OperatorSubscriber.ts:70:13)

It seems like that there are empty c/c1/cm elements in code block which force this exception. Further, for any other code block after this one, annotations don't get rendered at all.

Steps to reproduce

  1. Create project with mkdocs.yaml and index.md as provided
  2. Run mkdocs serve with provided versions

Package versions

  • Python: Python 3.9.10
  • MkDocs: 1.2.3
  • Material: 8.2.5

Configuration

site_name: Code Annotations with Terraform
theme:
  name: material
  features:
  - content.code.annotate
markdown_extensions:
  - pymdownx.highlight:
      anchor_linenums: true
  - pymdownx.inlinehilite
  - pymdownx.snippets
  - pymdownx.superfences

System information

  • Operating system: Windows 10
  • Browser:
    • Fire 5C27 fox 91.7.0esr (64-bit)
    • Chrome 99.0.4844.51 (Official Build) (64-bit)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue reports a bugresolvedIssue is resolved, yet unreleased if open

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0