Allow inlining code blocks with double quotes
This commit is contained in:
parent
9898bce41a
commit
a697f89083
@ -46,12 +46,12 @@ class SnipController extends AbstractController
|
||||
#[Route('/single/{snip}', name: '_single')]
|
||||
public function single(Snip $snip): Response
|
||||
{
|
||||
$snipParser = new Pipeline();
|
||||
$this->denyAccessUnlessGranted(SnipVoter::VIEW, $snip);
|
||||
|
||||
$snipService = $this->snipServiceFactory->create($snip);
|
||||
return $this->render('snip/single.html.twig', [
|
||||
'snip' => $snip,
|
||||
'content' => $snipParser->parse(($snipService->get())),
|
||||
'content' => (new Pipeline())->parse(($snipService->get())),
|
||||
'branch' => $snipService->getRepo()->getCurrentBranchName(),
|
||||
]);
|
||||
}
|
||||
|
@ -13,7 +13,8 @@ class Pipeline
|
||||
$builder = new PipelineBuilder();
|
||||
$pipeline = $builder
|
||||
->add(new HtmlEscapeStage())
|
||||
->add(new ReplaceBlocksStage('<pre><code>', '</code></pre>', '```'))
|
||||
->add(new ReplaceBlocksStage('<pre><code class="hljs">', '</code></pre>', '```'))
|
||||
->add(new ReplaceBlocksStage('<code class="hljs">', '</code>', '``'))
|
||||
->build();
|
||||
|
||||
return $pipeline->process($payload);
|
||||
|
@ -44,5 +44,11 @@
|
||||
{% block js %}
|
||||
{{ parent() }}
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script>
|
||||
<script>hljs.highlightAll();</script>
|
||||
<script>
|
||||
const codeBlocks = document.querySelectorAll('code.hljs');
|
||||
|
||||
codeBlocks.forEach((block) => {
|
||||
hljs.highlightElement(block);
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
Loading…
Reference in New Issue
Block a user