bash-hackers-wiki/howto/edit-ed/index.html

131 lines
66 KiB
HTML
Raw Permalink Normal View History

<!doctype html><html lang=en class=no-js> <head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><link href=https://flokoe.github.io/bash-hackers-wiki/howto/edit-ed/ rel=canonical><link href=../dissectabadoneliner/ rel=prev><link href=../getopts_tutorial/ rel=next><link rel=icon href=../../assets/images/favicon.png><meta name=generator content="mkdocs-1.6.1, mkdocs-material-9.5.44"><title>Editing files via scripts with ed - The Bash Hackers Wiki</title><link rel=stylesheet href=../../assets/stylesheets/main.0253249f.min.css><link rel=stylesheet href=../../assets/stylesheets/palette.06af60db.min.css><link rel=preconnect href=https://fonts.gstatic.com crossorigin><link rel=stylesheet href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback"><style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style><script>__md_scope=new URL("../..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script></head> <body dir=ltr data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo> <input class=md-toggle data-md-toggle=drawer type=checkbox id=__drawer autocomplete=off> <input class=md-toggle data-md-toggle=search type=checkbox id=__search autocomplete=off> <label class=md-overlay for=__drawer></label> <div data-md-component=skip> <a href=#editing-files-via-scripts-with-ed class=md-skip> Skip to content </a> </div> <div data-md-component=announce> </div> <header class=md-header data-md-component=header> <nav class="md-header__inner md-grid" aria-label=Header> <a href=../.. title="The Bash Hackers Wiki" class="md-header__button md-logo" aria-label="The Bash Hackers Wiki" data-md-component=logo> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54"/></svg> </a> <label class="md-header__button md-icon" for=__drawer> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg> </label> <div class=md-header__title data-md-component=header-title> <div class=md-header__ellipsis> <div class=md-header__topic> <span class=md-ellipsis> The Bash Hackers Wiki </span> </div> <div class=md-header__topic data-md-component=header-topic> <span class=md-ellipsis> Editing files via scripts with ed </span> </div> </div> </div> <form class=md-header__option data-md-component=palette> <input class=md-option data-md-color-media data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to dark mode" type=radio name=__palette id=__palette_0> <label class="md-header__button md-icon" title="Switch to dark mode" for=__palette_1 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a4 4 0 0 0-4 4 4 4 0 0 0 4 4 4 4 0 0 0 4-4 4 4 0 0 0-4-4m0 10a6 6 0 0 1-6-6 6 6 0 0 1 6-6 6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> <input class=md-option data-md-color-media data-md-color-scheme=slate data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to light mode" type=radio name=__palette id=__palette_1> <label class="md-header__button md-icon" title="Switch to light mode" for=__palette_0 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6a6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> </form> <script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===p
</code></pre></div> <p>To inject the needed newlines, etc. it may be easier to use the builtin command, <code>printf</code> ("help printf"). Shown here as an example Bash function to prefix text to file content:</p> <div class=highlight><pre><span></span><code># insertHead &quot;$text&quot; &quot;$file&quot;
insertHead() {
printf &#39;%s\n&#39; H 1i &quot;$1&quot; . w | ed -s &quot;$2&quot;
}
</code></pre></div> <p><strong><u>Here-strings</u></strong></p> <div class=highlight><pre><span></span><code>ed &lt;FILE&gt; &lt;&lt;&lt; &#39;&lt;ED-COMMANDS&gt;&#39;
</code></pre></div> <p><strong><u>Here-documents</u></strong></p> <div class=highlight><pre><span></span><code>ed &lt;FILE&gt; &lt;&lt;EOF
&lt;ED-COMMANDS&gt;
EOF
</code></pre></div> <p>Which one you prefer is your choice. I will use the here-strings, since it looks best here IMHO.</p> <p>There are other ways to provide input to <code>ed</code>. For example, process substitution. But these should be enough for daily needs.</p> <p>Since <code>ed</code> wants commands separated by newlines, I'll use a special Bash quoting method, the C-like strings <code>$'TEXT'</code>, as it can interpret a set of various escape sequences and special characters. I'll use the <code>-s</code> option to make it less verbose.</p> <h2 id=the-basic-interface>The basic interface<a class=headerlink href=#the-basic-interface title="Permanent link">&para;</a></h2> <p>Check the <code>ed</code> manpage for details</p> <p>Similar to <code>vi</code> or <code>vim</code>, <code>ed</code> has a "command mode" and an "interactive mode". For non-interactive use, the command mode is the usual choice.</p> <p>Commands to <code>ed</code> have a simple and regular structure: zero, one, or two addresses followed by a single-character command, possibly followed by parameters to that command. These addresses specify one or more lines in the text buffer. Every command that requires addresses has default addresses, so the addresses can often be omitted.</p> <p>The line addressing is relative to the <em>current line</em>. If the edit buffer is not empty, the initial value for the <em>current line</em> shall be the last line in the edit buffer, otherwise zero. Generally, the <em>current line</em> is the last line affected by a command. All addresses can only address single lines, not blocks of lines!</p> <p>Line addresses or commands using <em>regular expressions</em> interpret POSIX Basic Regular Expressions (BRE). A null BRE is used to reference the most recently used BRE. Since <code>ed</code> addressing is only for single lines, no RE can ever match a newline.</p> <h2 id=debugging-your-ed-scripts>Debugging your ed scripts<a class=headerlink href=#debugging-your-ed-scripts title="Permanent link">&para;</a></h2> <p>By default, <code>ed</code> is not very talkative and will simply print a "?" when an error occurs. Interactively you can use the <code>h</code> command to get a short message explaining the last error. You can also turn on a mode that makes <code>ed</code> automatically print this message with the <code>H</code> command. It is a good idea to always add this command at the beginning of your ed scripts:</p> <div class=highlight><pre><span></span><code>bash &gt; ed -s file &lt;&lt;&lt; $&#39;H\n,df&#39;
?
script, line 2: Invalid command suffix
</code></pre></div> <p>While working on your script, you might make errors and destroy your file, you might be tempted to try your script doing something like:</p> <div class=highlight><pre><span></span><code># Works, but there is better
# copy my original file
cp file file.test
# try my script on the file
ed -s file.test &lt;&lt;&lt; $&#39;H\n&lt;ed commands&gt;\nw&#39;
# see the results
cat file.test
</code></pre></div> <p>There is a much better way though, you can use the ed command <code>p</code> to print the file, now your testing would look like:</p> <div class=highlight><pre><span></span><code>ed -s file &lt;&lt;&lt; $&#39;H\n&lt;ed commands&gt;\n,p&#39;
</code></pre></div> <p>the <code>,</code> (comma) in front of the <code>p</code> command is a shortcut for <code>1,$</code> which defines an address range for the first to the last line, <code>,p</code> thus means print the whole file, after it has been modified. When your script runs sucessfully, you only have to replace the <code>,p</code> by a <code>w</code>.</p> <p>Of course, even if the file is not modified by the <code>p</code> command, <strong>it's always a good idea to have a backup copy!</strong></p> <h2 id=editing-your-files>Editing your files<a class=headerlink href=#editing-your-files title="Permanent link">&para;</a></h2> <p>Most of these things can be done with <code>sed</code>. But there are also things that can't be done in <code>sed</code> or can only be done with very complex code.</p> <h3 id=simple-word-substitutions>Simple word substitutions<a class=headerlink href=#simple-word-substitutions title="Permanent link">&para;</a></h3> <p>Like <code>sed</code>, <code>ed</code> also knows the common <code>s/FROM/TO/</code> command, and it can also take line-addresses. <strong>If no substitution is made on the addressed lines, it's considered an error.</strong></p> <h4 id=substitutions-through-the-whole-file>Substitutions through the whole file<a class=headerlink href=#substitutions-through-the-whole-file title="Permanent link">&para;</a></h4> <div class=highlight><pre><span></span><code>ed -s test.txt &lt;&lt;&lt; $&#39;,s/Windows(R)-compatible/POSIX-conform/g\nw&#39;
</code></pre></div> <p><u>Note:</u> The comma as single address operator is an alias for <code>1,$</code> ("all lines").</p> <h4 id=substitutions-in-specific-lines>Substitutions in specific lines<a class=headerlink href=#substitutions-in-specific-lines title="Permanent link">&para;</a></h4> <p>On a line containing <code>fruits</code>, do the substitution:</p> <div class=highlight><pre><span></span><code>ed -s test.txt &lt;&lt;&lt; $&#39;/fruits/s/apple/banana/g\nw&#39;
</code></pre></div> <p>On the 5<sup>th</sup> line after the line containing <code>fruits</code>, do the substitution:</p> <div class=highlight><pre><span></span><code>ed -s test.txt &lt;&lt;&lt; $&#39;/fruits/+5s/apple/banana/g\nw&#39;
</code></pre></div> <h3 id=block-operations>Block operations<a class=headerlink href=#block-operations title="Permanent link">&para;</a></h3> <h4 id=delete-a-block-of-text>Delete a block of text<a class=headerlink href=#delete-a-block-of-text title="Permanent link">&para;</a></h4> <p>The simple one is a well-known (by position) block of text:</p> <div class=highlight><pre><span></span><code># delete lines number 2 to 4 (2, 3, 4)
ed -s test.txt &lt;&lt;&lt; $&#39;2,5d\nw&#39;
</code></pre></div> <p>This deletes all lines matching a specific regular expression:</p> <div class=highlight><pre><span></span><code># delete all lines matching foobar
ed -s test.txt &lt;&lt;&lt; $&#39;g/foobar/d\nw&#39;
</code></pre></div> <p>g/regexp/ applies the command following it to all the lines matching the regexp</p> <h4 id=move-a-block-of-text>Move a block of text<a class=headerlink href=#move-a-block-of-text title="Permanent link">&para;</a></h4> <p>...using the <code>m</code> command: <code>&lt;ADDRESS&gt; m &lt;TARGET-ADDRESS&gt;</code></p> <p>This is definitely something that can't be done easily with sed.</p> <div class=highlight><pre><span></span><code># moving lines 5-9 to the end of the file
ed -s test.txt &lt;&lt;&lt; $&#39;5,9m$\nw&#39;
# moving lines 5-9 to line 3
ed -s test.txt &lt;&lt;&lt; $&#39;5,9m3\nw&#39;
</code></pre></div> <h4 id=copy-a-block-of-text>Copy a block of text<a class=headerlink href=#copy-a-block-of-text title="Permanent link">&para;</a></h4> <p>...using the <code>t</code> command: <code>&lt;ADDRESS&gt; t &lt;TARGET-ADDRESS&gt;</code></p> <p>You use the <code>t</code> command just like you use the <code>m</code> (move) command.</p> <div class=highlight><pre><span></span><code># make a copy of lines 5-9 and place it at the end of the file
ed -s test.txt &lt;&lt;&lt; $&#39;5,9t$\nw&#39;
# make a copy of lines 5-9 and place it at line 3
ed -s test.txt &lt;&lt;&lt; $&#39;5,9t3\nw&#39;
</code></pre></div> <h4 id=join-all-lines>Join all lines<a class=headerlink href=#join-all-lines title="Permanent link">&para;</a></h4> <p>...but leave the final newline intact. This is done by an extra command: <code>j</code> (join).</p> <div class=highlight><pre><span></span><code>ed -s file &lt;&lt;&lt; $&#39;1,$j\nw&#39;
</code></pre></div> <p>Compared with two other methods (using <code>tr</code> or <code>sed</code>), you don't have to delete all newlines and manually add one at the end.</p> <h3 id=file-operations>File operations<a class=headerlink href=#file-operations title="Permanent link">&para;</a></h3> <h4 id=insert-another-file>Insert another file<a class=headerlink href=#insert-another-file title="Permanent link">&para;</a></h4> <p>How do you insert another file? As with <code>sed</code>, you use the <code>r</code> (read) command. That inserts another file at the line before the last line (and prints the result to stdout - <code>,p</code>):</p> <div class=highlight><pre><span></span><code>ed -s FILE1 &lt;&lt;&lt; $&#39;$-1 r FILE2\n,p&#39;
</code></pre></div> <p>To compare, here's a possible <code>sed</code> solution which must use Bash arithmetic and the external program <code>wc</code>:</p> <div class=highlight><pre><span></span><code>sed &quot;$(($(wc -l &lt; FILE1)-1))r FILE2&quot; FILE1
# UPDATE here&#39;s one which uses GNU sed&#39;s &quot;e&quot; parameter for the s-command
# it executes the commands found in pattern space. I&#39;ll take that as a
# security risk, but well, sometimes GNU &gt; security, you know...
sed &#39;${h;s/.*/cat FILE2/e;G}&#39; FILE1
</code></pre></div> <p>Another approach, in two invocations of sed, that avoids the use of external commands completely:</p> <div class=highlight><pre><span></span><code>sed $&#39;${s/$/\\n-||-/;r FILE2\n}&#39; FILE1 | sed &#39;0,/-||-/{//!h;N;//D};$G&#39;
</code></pre></div> <h2 id=pitfalls>Pitfalls<a class=headerlink href=#pitfalls title="Permanent link">&para;</a></h2> <h3 id=ed-is-not-sed>ed is not sed<a class=headerlink href=#ed-is-not-sed title="Permanent link">&para;</a></h3> <p>ed and sed might look similar, but the same command(s) might act differently:</p> <p><strong>__ /foo/d __</strong></p> <p>In sed /foo/d will delete all lines matching foo, in ed the commands are not repeated on each line so this command will search the next line matching foo and delete it. If you want to delete all lines matching foo, or do a subsitution on all lines matching foo you have to tell ed about it with the g (global) command:</p> <div class=highlight><pre><span></span><code>echo $&#39;1\n1\n3&#39; &gt; file
#replace all lines matching 1 by &quot;replacement&quot;
ed -s file &lt;&lt;&lt; $&#39;g/1/s/1/replacement/\n,p&#39;
#replace the first line matching 1 by &quot;replacement&quot;
#(because it starts searching from the last line)
ed -s file &lt;&lt;&lt; $&#39;s/1/replacement/\n,p&#39;
</code></pre></div> <p><strong>__ an error stops the script __</strong></p> <p>You might think that it's not a problem and that the same thing happens with sed and you're right, with the exception that if ed does not find a pattern it's an error, while sed just continues with the next line. For instance, let's say that you want to change foo to bar on the first line of the file and add something after the next line, ed will stop if it cannot find foo on the first line, sed will continue.</p> <div class=highlight><pre><span></span><code>#Gnu sed version
sed -e &#39;1s/foo/bar/&#39; -e &#39;$a\something&#39; file
#First ed version, does nothing if foo is not found on the first line:
ed -s file &lt;&lt;&lt; $&#39;H\n1s/foo/bar/\na\nsomething\n.\nw&#39;
</code></pre></div> <p>If you want the same behaviour you can use g/foo/ to trick ed. g/foo/ will apply the command on all lines matching foo, thus the substitution will succeed and ed will not produce an error when foo is not found:</p> <div class=highlight><pre><span></span><code>#Second version will add the line with &quot;something&quot; even if foo is not found
ed -s file &lt;&lt;&lt; $&#39;H\n1g/foo/s/foo/bar/\na\nsomething\n.\nw&#39;
</code></pre></div> <p>In fact, even a substitution that fails after a g/ / command does not seem to cause an error, i.e. you can use a trick like g/./s/foo/bar/ to attempt the substitution on all non blank lines</p> <h3 id=here-documents>here documents<a class=headerlink href=#here-documents title="Permanent link">&para;</a></h3> <p><strong>__ shell parameters are expanded __</strong></p> <p>If you don't quote the delimiter, <code>$</code> has a special meaning. This sounds obvious but it's easy to forget this fact when you use addresses like <code>$-1</code> or commands like <code>$a</code>. Either quote the <code>$</code> or the delimiter:</p> <div class=highlight><pre><span></span><code>#fails
ed -s file &lt;&lt; EOF
$a
last line
.
w
EOF
#ok
ed -s file &lt;&lt; EOF
$a
last line
.
w
EOF
#ok again
ed -s file &lt;&lt; &#39;EOF&#39;
$a
last line
.
w
EOF
</code></pre></div> <p><strong>__ "." is not a command __</strong></p> <p>The . used to terminate the command "a" must be the only thing on the line. take care if you indent the commands:</p> <div class=highlight><pre><span></span><code>#ed doesn&#39;t care about the spaces before the commands, but the . must be the only thing on the line:
ed -s file &lt;&lt; EOF
a
my content
.
w
EOF
</code></pre></div> <h2 id=simulate-other-commands>Simulate other commands<a class=headerlink href=#simulate-other-commands title="Permanent link">&para;</a></h2> <p>Keep in mind that in all the examples below, the entire file will be read into memory.</p> <h3 id=a-simple-grep>A simple grep<a class=headerlink href=#a-simple-grep title="Permanent link">&para;</a></h3> <div class=highlight><pre><span></span><code>ed -s file &lt;&lt;&lt; &#39;g/foo/p&#39;
# equivalent
ed -s file &lt;&lt;&lt; &#39;g/foo/&#39;
</code></pre></div> <p>The name <code>grep</code> is derived from the notaion <code>g/RE/p</code> (global =&gt; regular expression =&gt; print). ref <a href=http://www.catb.org/~esr/jargon/html/G/grep.html>http://www.catb.org/~esr/jargon/html/G/grep.html</a></p> <h3 id=wc-l>wc -l<a class=headerlink href=#wc-l title="Permanent link">&para;</a></h3> <p>Since the default for the <code>ed</code> "print line number" command is the last line, a simple <code>=</code> (equal sign) will print this line number and thus the number of lines of the file:</p> <div class=highlight><pre><span></span><code>ed -s file &lt;&lt;&lt; &#39;=&#39;
</code></pre></div> <h3 id=cat>cat<a class=headerlink href=#cat title="Permanent link">&para;</a></h3> <p>Yea, it's a joke...</p> <div class=highlight><pre><span></span><code>ed -s file &lt;&lt;&lt; $&#39;,p&#39;
</code></pre></div> <p>...but a similar thing to <code>cat</code> showing line-endings and escapes can be done with the <code>list</code> command (l):</p> <div class=highlight><pre><span></span><code>ed -s file &lt;&lt;&lt; $&#39;,l&#39;
</code></pre></div> <div class="admonition warning"> <p class=admonition-title>FIXME</p> <p>to be continued</p> </div> <h2 id=links>Links<a class=headerlink href=#links title="Permanent link">&para;</a></h2> <p>Reference:</p> <ul> <li><a href=http://www.gnu.org/software/ed/manual/ed_manual.html>Gnu ed</a> - if we had to guess, you're probably using this one.</li> <li>POSIX <a href=http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ed.html#tag_20_38>ed</a>, <a href=http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ex.html#tag_20_40>ex</a>, and <a href=http://pubs.opengroup.org/onlinepubs/9699919799/utilities/vi.html#tag_20_152>vi</a></li> <li><a href=http://sdf.lonestar.org/index.cgi?tutorials/ed>http://sdf.lonestar.org/index.cgi?tutorials/ed</a> - ed cheatsheet on sdf.org</li> </ul> <p>Misc info / tutorials:</p> <ul> <li><a href=http://mywiki.wooledge.org/BashFAQ/021>How can I replace a string with another string in a variable, a stream, a file, or in all the files in a directory?</a> - BashFAQ</li> <li><a href=http://wolfram.schneider.org/bsd/7thEdManVol2/edtut/edtut.pdf>http://wolfram.schneider.org/bsd/7thEdManVol2/edtut/edtut.pdf</a> - Old but still relevant ed tutorial.</li> </ul> <aside class=md-source-file> <span class=md-source-file__fact> <span class=md-icon title="Last update"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M21 13.1c-.1 0-.3.1-.4.2l-1 1 2.1 2.1 1-1c.2-.2.2-.6 0-.8l-1.3-1.3c-.1-.1-.2-.2-.4-.2m-1.9 1.8-6.1 6V23h2.1l6.1-6.1zM12.5 7v5.2l4 2.4-1 1L11 13V7zM11 21.9c-5.1-.5-9-4.8-9-9.9C2 6.5 6.5 2 12 2c5.3 0 9.6 4.1 10 9.3-.3-.1-.6-.2-1-.2s-.7.1-1 .2C19.6 7.2 16.2 4 12 4c-4.4 0-8 3.6-8 8 0 4.1 3.1 7.5 7.1 7.9l-.1.2z"/></svg> </span> <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date">November 13, 2024</span> </span> <span class=md-source-file__fact> <span class=md-icon title=Created> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M14.47 15.08 11 13V7h1.5v5.25l3.08 1.83c-.41.28-.79.62-1.11 1m-1.39 4.84c-.36.05-.71.08-1.08.08-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8c0 .37-.03.72-.08 1.08.69.1 1.33.32 1.92.64.1-.56.16-1.13.16-1.72 0-5.5-4.5-10-10-10S2 6.5 2 12s4.47 10 10 10c.59 0 1.16-.06 1.72-.16-.32-.59-.54-1.23-.64-1.92M18 15v3h-3v2h3v3h2v-3h3v-2h-3v-3z"/></svg> </span> <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date">November 13, 2024</span> </span> </aside> <h2 id=__comments>Comments</h2> <script src=https://giscus.app/client.js data-repo=flokoe/bash-hackers-wiki data-repo-id=R_kgDOJ3Nr6Q data-category="Giscus Page Comments" data-category-id=DIC_kwDOJ3Nr6c4CXq9t data-mapping=pathname data-strict=1 data-reactions-enabled=1 data-emit-metadata=0 data-input-position=top data-theme=preferred_color_scheme data-lang=en data-loading=lazy crossorigin=anonymous async>
</script> <script>
var giscus = document.querySelector("script[src*=giscus]")
/* Set palette on initial load */
var palette = __md_get("__palette")
if (palette && typeof palette.color === "object") {
var theme = palette.color.scheme === "slate" ? "dark" : "light"
giscus.setAttribute("data-theme", theme)
}
/* Register event handlers after documented loaded */
document.addEventListener("DOMContentLoaded", function() {
var ref = document.querySelector("[data-md-component=palette]")
ref.addEventListener("change", function() {
var palette = __md_get("__palette")
if (palette && typeof palette.color === "object") {
var theme = palette.color.scheme === "slate" ? "dark" : "light"
/* Instruct Giscus to change theme */
var frame = document.querySelector(".giscus-frame")
frame.contentWindow.postMessage(
{ giscus: { setConfig: { theme } } },
"https://giscus.app"
)
}
})
})
</script> </article> </div> <script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script> </div> <button type=button class="md-top md-icon" data-md-component=top hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8z"/></svg> Back to top </button> </main> <footer class=md-footer> <div class="md-footer-meta md-typeset"> <div class="md-footer-meta__inner md-grid"> <div class=md-copyright> Made with <a href=https://squidfunk.github.io/mkdocs-material/ target=_blank rel=noopener> Material for MkDocs </a> </div> </div> </div> </footer> </div> <div class=md-dialog data-md-component=dialog> <div class="md-dialog__inner md-typeset"></div> </div> <script id=__config type=application/json>{"base": "../..", "features": ["navigation.instant", "navigation.tracking", "navigation.tabs", "navigation.sections", "navigation.top", "content.action.view", "content.action.edit", "search.suggest", "search.highlight", "content.code.copy"], "search": "../../assets/javascripts/workers/search.6ce7567c.min.js", "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}}</script> <script src=../../assets/javascripts/bundle.83f73b43.min.js></script> </body> </html>