Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #76
Copying implementation instructions from issue:
types.d.ts
I mentioned above.schema.graphql
to represent inline code. It should look just likeGRVSCCodeBlock
, bet can replacepreClassName
andcodeClassName
with justclassName
, omitmeta
, and replacetokenizedLines
withtokens: [GRVSCToken!]!
. (Runnpm run build
after this to updateschema.d.ts
.)options.inlineCode
exists,options.inlineCode.marker
must exist invalidateOptions.js
.code
andinlineCode
nodes, ifoptions.inlineCode
is defined. (I think you can replace the string'code'
test with a callback function that accepts a node, where you can check itstype
. API)node.type
for some things. E.g., instead of callingparseCodeFenceHeader
, you’ll need to call a new similar parsing function that separates the node text intolanguage
andtext
. If you don’t detect a language (i.e., you never seeinlineCode.marker
), I think you can justcontinue
and be done with that node. The call togetPossibleThemes
needs to useinlineCode.theme || theme
ifnode.type === 'inlineCode'
. Otherwise, I think most of that loop body stays the same. In theregisterCodeBlock
function, I think we should probably not run line transformers on inline code nodes.registry.forEachCodeBlock
, goes back over the nodes and generates HTML for them. The actual HTML generation is ingetCodeBlockDataFromRegistry
. Probably about half the stuff in here is actually specific to code blocks, and I think it might be too messy to make it polymorphic, so I would probably recommend makingregistry.forEachInlineCode
andgetInlineCodeDataFromRegistry
functions instead, and repeating/extracting the relevant things from what’s there now. While generating HTML is the bulk of the work in this function, its full purpose is to generate a JavaScript object matching the new type you added to the GraphQL schema in step 2.index.js
in your[codeBlockRegistry.forEachInlineCode]
loop, you can finish generating the GraphQL node in the same way asregistry.forEachCodeBlock
and push it onto the samegraphQLNodes
array.And a step I forgot:
GRVSCCodeSpan
ingatsby-config.js