-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #608 from wouterj/default-highlight-language
Allow setting a default language for literal blocks
- Loading branch information
Showing
10 changed files
with
92 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...ges/guides-restructured-text/src/RestructuredText/Parser/DocumentParserContextFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace phpDocumentor\Guides\RestructuredText\Parser; | ||
|
||
use phpDocumentor\Guides\RestructuredText\MarkupLanguageParser; | ||
use phpDocumentor\Guides\RestructuredText\TextRoles\TextRoleFactory; | ||
use phpDocumentor\Guides\Settings\SettingsManager; | ||
|
||
class DocumentParserContextFactory | ||
{ | ||
public function __construct( | ||
private readonly TextRoleFactory $textRoleFactory, | ||
private readonly SettingsManager $settingsManager, | ||
) { | ||
} | ||
|
||
public function create(MarkupLanguageParser $markupLanguageParser): DocumentParserContext | ||
{ | ||
$documentParser = new DocumentParserContext( | ||
$markupLanguageParser->getParserContext(), | ||
$this->textRoleFactory, | ||
$markupLanguageParser, | ||
); | ||
|
||
$documentParser->setCodeBlockDefaultLanguage($this->settingsManager->getProjectSettings()->getDefaultCodeLanguage()); | ||
|
||
return $documentParser; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
tests/Integration/tests/code/literal-block-default-language-php/expected/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>Code Block</title> | ||
|
||
</head> | ||
<body> | ||
<div class="section" id="code-block"> | ||
<h1>Code Block</h1> | ||
|
||
<pre><code class="language-php">$some = 'PHP'; | ||
</code></pre> | ||
<pre><code class="language-php">$someThing = 'else';</code></pre> | ||
</div> | ||
|
||
</body> | ||
</html> |
7 changes: 7 additions & 0 deletions
7
tests/Integration/tests/code/literal-block-default-language-php/input/guides.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<guides xmlns="https://www.phpdoc.org/guides" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="https://www.phpdoc.org/guides packages/guides-cli/resources/schema/guides.xsd" | ||
default-code-language="php" | ||
> | ||
</guides> |
10 changes: 10 additions & 0 deletions
10
tests/Integration/tests/code/literal-block-default-language-php/input/index.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Code Block | ||
========== | ||
|
||
:: | ||
|
||
$some = 'PHP'; | ||
|
||
.. code-block:: | ||
$someThing = 'else'; |