File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -847,7 +847,7 @@ def _locate_text(text: str) -> int:
847847 span = (line ,)
848848 language = options ["language" ] if "language" in options else ""
849849 caption = options ["caption" ] if "caption" in options else None
850- copyable = "copyable" not in options or options ["copyable" ] == "True"
850+ copyable = "copyable" not in options or options ["copyable" ] != False
851851 selected_content = "\n " .join (lines )
852852 linenos = "linenos" in options
853853 lineno_start = (
Original file line number Diff line number Diff line change @@ -953,6 +953,33 @@ def test_literalinclude() -> None:
953953 </root>""" ,
954954 )
955955
956+ # Test a literally-included code block with copyable option specified
957+ page , diagnostics = parse_rst (
958+ parser ,
959+ path ,
960+ """
961+ .. literalinclude:: /test_parser/includes/sample_code.js
962+ :language: json
963+ :copyable: true
964+ :emphasize-lines: 5
965+ """ ,
966+ )
967+ page .finish (diagnostics )
968+ assert diagnostics == []
969+ check_ast_testing_string (
970+ page .ast ,
971+ """<root fileid="test.rst">
972+ <directive name="literalinclude" language="json" emphasize-lines="5" copyable="True">
973+ <text>/test_parser/includes/sample_code.js</text>
974+ <code lang="json" emphasize_lines="[(5, 5)]" copyable="True">var str = "sample code";
975+ var i = 0;
976+ for (i = 0; i < 10; i++) {
977+ str += i;
978+ }</code>
979+ </directive>
980+ </root>""" ,
981+ )
982+
956983 # Test a literally-included code block with fully specified options
957984 page , diagnostics = parse_rst (
958985 parser ,
You can’t perform that action at this time.
0 commit comments