luckasRanarison / nvim-devdocs

Neovim DevDocs integration
MIT License
270 stars 20 forks source link

Error when installing WordPress docs #75

Closed nathabonfim59 closed 7 months ago

nathabonfim59 commented 7 months ago

First off, awesome plugin! Having all my docs in the terminal is incredible for a "CLI junkie" like myself.

When I try to install the WordPress docs, I get this error.

Command: :DevdocsInstall wordpres

:version
NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1692716794

Package Manager: Lazy
[nvim-devdocs] Downloading wordpress documentation...
[nvim-devdocs] Converting functions/add_image_size (6792/9509)wordpress/6791.md has been writen509)6734/9509)9)9)))1/9509)
[nvim-devdocs] Failed to convert "functions/add_image_size", please report this issue
...ck/lazy/opt/nvim-devdocs/lua/nvim-devdocs/transpiler.lua:292: bad argument #1 to 'match' (string expected, got nil)
stack traceback:
^I[C]: in function 'match'
^I...ck/lazy/opt/nvim-devdocs/lua/nvim-devdocs/transpiler.lua:292: in function 'eval'
^I...ck/lazy/opt/nvim-devdocs/lua/nvim-devdocs/transpiler.lua:356: in function 'eval_child'
^I...ck/lazy/opt/nvim-devdocs/lua/nvim-devdocs/transpiler.lua:283: in function 'eval'
^I...ck/lazy/opt/nvim-devdocs/lua/nvim-devdocs/transpiler.lua:356: in function 'eval_child'
^I...ck/lazy/opt/nvim-devdocs/lua/nvim-devdocs/transpiler.lua:283: in function 'eval'
^I...ck/lazy/opt/nvim-devdocs/lua/nvim-devdocs/transpiler.lua:251: in function 'fn'
^I...r/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:345: in function 'for_each_tree'
^I...ck/lazy/opt/nvim-devdocs/lua/nvim-devdocs/transpiler.lua:246: in function <...ck/lazy/opt/nvim-devdocs/lua/nvim-devdocs/transpiler.lua:245>
^I[C]: in function 'xpcall'
^I...te/pack/lazy/opt/nvim-devdocs/lua/nvim-devdocs/build.lua:47: in function 'build_docs'
^I...ck/lazy/opt/nvim-devdocs/lua/nvim-devdocs/operations.lua:73: in function ''
^Ivim/_editor.lua: in function <vim/_editor.lua:0>
Original html document:
<h1>add_image_size( string $name, int $width, int $height, bool|array $crop = false )</h1>  <section> <p>Registers a new image size.</p> </section>   <section> <header class="toc-header"><h2 id="parameters">Parameters</h2></header> <dl> <dt> <code>$name</code> <span class="type"><span class="string">string</span></
span> <span class="required">Required</span> </dt> <dd> <div class="desc"> <span class="description">Image size identifier.</span> </div> </dd> <dt> <code>$width</code> <span class="type"><span class="int">int</span></span> <span class="required">Optional</span> </dt> <dd> <div class="desc"> <span class="descriptio
n"> Image width in pixels. Default 0.</span> </div> </dd> <dt> <code>$height</code> <span class="type"><span class="int">int</span></span> <span class="required">Optional</span> </dt> <dd> <div class="desc"> <span class="description"> Image height in pixels. Default 0.</span> </div> </dd> <dt> <code>$crop</code> <s
pan class="type"><span class="bool">bool</span>|<span class="array">array</span></span> <span class="required">Optional</span> </dt> <dd> <div class="desc"> <span class="description"> Image cropping behavior. If false, the image will be scaled (default), If true, image will be cropped to the specified dimensions us
ing center positions.<br> If an array, the image will be cropped using the array to specify the crop location.<br> Array values must be in the format: array( x_crop_position, y_crop_position ) where:<br> <ul>
<li>x_crop_position accepts: <code>'left'</code>, <code>'center'</code>, or <code>'right'</code>.</li> <li>y_crop_position accepts: <code>'top'</code>, <code>'center'</code>, or <code>'bottom'</code>.</li>
</ul></span> </div> <p class="default">Default: <code>false</code></p> </dd> </dl> </section>  <section> <header class="toc-header"><h2 id="more-information">More Information</h2></header> <header class="toc-header"><h3 id="reserved-image-size-names">Reserved Image Size Names</h3></header> <p>These are the reserved
 image size names recognized by WordPress: ‘thumb’, ‘thumbnail’, ‘medium’, ‘medium_large’, ‘large’, and ‘post-thumbnail’.</p> <p>The names “thumb” &amp; “thumbnail” are just aliases- they are exactly the same.</p> <p>For a detailed explanation and “why”, read further inside the <a href="image_downsize" rel="functio
n">image_downsize()</a> article.</p> <p>However, if needed, you can always set the options yourself:</p> <pre class="wp-block-code" data-language="php"><code lang="php" class="language-php ">update_option( 'thumbnail_size_w', 160 );
update_option( 'thumbnail_size_h', 160 );
update_option( 'thumbnail_crop', 1 );</code></pre>  <header class="toc-header"><h3 id="crop-mode">Crop Mode</h3></header> <p><strong>Set the image size by resizing the image proportionally (without distorting it):</strong><br> </p>
<pre class="wp-block-code" data-language="php"><code lang="php" class="language-php ">add_image_size( 'custom-size', 220, 180 ); // 220 pixels wide by 180 pixels tall, soft proportional crop mode</code></pre> <p><strong>Set the image size by cropping the image (not showing part of it):</strong><br> </p>
<pre class="wp-block-code" data-language="php"><code lang="php" class="language-php ">add_image_size( 'custom-size', 220, 180, true ); // 220 pixels wide by 180 pixels tall, hard crop mode</code></pre> <p><strong>Set the image size by cropping the image and defining a crop position:</strong><br> </p>
<pre class="wp-block-code" data-language="php"><code lang="php" class="language-php ">add_image_size( 'custom-size', 220, 220, array( 'left', 'top' ) ); // Hard crop left top</code></pre> <p><strong>When setting a crop position, the first value in the array is the x axis crop position, the second is the y axis crop
 position.</strong></p> <ul> <li>x_crop_position accepts ‘left’ ‘center’, or ‘right’.</li> <li>y_crop_position accepts ‘top’, ‘center’, or ‘bottom’.</li> </ul> <p>By default, these values default to ‘center’ when using hard crop mode.</p> <p>You can find examples of the various crop types <a href="https://havecamer
awilltravel.com/photographer/wordpress-thumbnail-crop">here</a>.</p>  <header class="toc-header"><h3 id="using-the-new-image-sizes">Using the New Image Sizes</h3></header> <p>Now that you’ve defined some custom image sizes, there are a variety of ways that you can use them.<br> For Featured Images</p> <p>To use you
r custom image sizes for a post’s featured image, you can use <a href="the_post_thumbnail" rel="function">the_post_thumbnail()</a> in the appropriate theme template file…</p> <p>Note: To enable featured images the current theme must include add_theme_support( ‘post-thumbnails’ ); in its functions.php file. See also
 Post Thumbnails.</p> <pre class="wp-block-code" data-language="php"><code lang="php" class="language-php ">if ( has_post_thumbnail() ) {
^Ithe_post_thumbnail( 'your-custom-size' );
}</code></pre>  <header class="toc-header"><h3 id="for-media-library-images-admin">For Media Library Images (Admin)</h3></header> <p>You can also make your custom sizes selectable from your WordPress admin. To do so, you have to use the image_size_names_choose hook to assign them a normal, human-readable name…</p>
<pre class="wp-block-code" data-language="php"><code lang="php" class="language-php line-numbers">add_filter( 'image_size_names_choose', 'my_custom_sizes' );
function my_custom_sizes( $sizes ) {
    return array_merge( $sizes, array(
        'your-custom-size' =&gt; __( 'Your Custom Size Name' ),
    ) );
}</code></pre>  <header class="toc-header"><h3 id="for-general-media-php-templates">For General Media (PHP/Templates)</h3></header> <p>You can output images (by size) directly from the WordPress Media Library using PHP as well. To do this, simply use <a href="wp_get_attachment_image" rel="function">wp_get_attachmen
t_image()</a> .</p> <pre class="wp-block-code" data-language="php"><code lang="php" class="language-php ">// Assuming your Media Library image has a post id of 42...
echo wp_get_attachment_image( 42, 'your-custom-size' );</code></pre> <p>Note: If you just want the image URL instead of a pre-built <img> tag, you can use <a href="wp_get_attachment_image_src" rel="function">wp_get_attachment_image_src()</a> instead.</p>  <header class="toc-header"><h3 id="other-notes">Other Notes:
</h3></header> <p>Using the ‘false’ setting will fail to produce a new image in the upload directory if one of the image dimensions of the uploaded image are equal to the new image size.</p> <p>If a registered image size is removed from functions.php, then any image uploaded before that point and then deleted from
the media library afterwards, does not have those auto-generated sizes deleted too. Only image sizes that exist in functions.php are deleted.</p> <p>Although height and width are not required parameters, their default values (0) will lead to unwanted behavior, so bear in mind that you should always define them. Use
 a value of 9999 to define the other dimension as the one to be considered when image resize is executed. </p> </section>  <section> <header class="toc-header"><h2 id="source">Source</h2></header> <p> File: <code>wp-includes/media.php</code>. <a href="https://developer.wordpress.org/reference/files/wp-includes/medi
a.php/">View all references</a> </p> <pre class="wp-block-code" data-start="291" aria-label="Function source code" data-language="php"><code lang="php" class="language-php line-numbers">function add_image_size( $name, $width = 0, $height = 0, $crop = false ) {
^Iglobal $_wp_additional_image_sizes;
^I$_wp_additional_image_sizes[ $name ] = array(
^I^I'width'  =&gt; absint( $width ),
^I^I'height' =&gt; absint( $height ),
^I^I'crop'   =&gt; $crop,
^I);
}
</code></pre>  </section>  <section> <header class="toc-header"><h2 id="related">Related</h2></header> <article class="uses"> <header class="toc-header"><h3 id="uses">Uses</h3></header> <table id="uses-table" data-show="2">  <thead> <tr> <th>Uses</th> <th class="related-desc">Description</th> </tr> </thead> <tbody>
 <tr> <td class="related-title"> <a href="absint">absint()</a> <span>wp-includes/functions.php</span> </td> <td class="related-desc"> <p>Converts a value to non-negative integer.</p> </td> </tr> </tbody>
</table> </article> <article class="used-by"> <header class="toc-header"><h3 id="used-by">Used By</h3></header> <table id="used-by-table" data-show="5">  <thead> <tr> <th>Used By</th> <th class="related-desc">Description</th> </tr> </thead> <tbody> <tr> <td class="related-title"> <a href="_wp_add_additional_image_s
izes">_wp_add_additional_image_sizes()</a> <span>wp-includes/media.php</span> </td> <td class="related-desc"> <p>Adds additional default image sub-sizes.</p> </td> </tr> <tr> <td class="related-title"> <a href="set_post_thumbnail_size">set_post_thumbnail_size()</a> <span>wp-includes/media.php</span> </td> <td class
="related-desc"> <p>Registers an image size for the post thumbnail.</p> </td> </tr> </tbody>
</table> </article> </section>  <section> <header class="toc-header"><h2 id="changelog">Changelog</h2></header> <table>  <thead> <tr> <th class="changelog-version">Version</th> <th class="changelog-desc">Description</th> </tr> </thead> <tbody> <tr> <td><a href="https://developer.wordpress.org/reference/since/2.9.0/
" alt="WordPress 2.9.0">2.9.0</a></td> <td>Introduced.</td> </tr> </tbody> </table> </section><div class="_attribution">
luckasRanarison commented 7 months ago

Hi, could you check if it works now?

nathabonfim59 commented 7 months ago

Works perfectly. Thank you!