1
1
mirror of https://github.com/wader/fq.git synced 2024-11-27 06:04:47 +03:00

Merge pull request #497 from wader/help-nicer-line-break

interp,help: Properly count line length when breaking on whole words
This commit is contained in:
Mattias Wadman 2022-11-29 19:08:00 +01:00 committed by GitHub
commit 36ea3a95cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 10 deletions

View File

@ -1,9 +1,9 @@
def _markdown__todisplay: tovalue;
def word_break($width):
def _word_break($width):
def _f($a; $acc; $l):
( $a[0] as $w
| ($w // "" | length) as $wl
| ($w // "" | length+1) as $wl
| if $w == null then $acc
elif ($l + $wl) >= $width then
( $acc
@ -17,7 +17,7 @@ def word_break($width):
);
def _markdown_to_text($width; $header_depth):
def lb: if $width > 0 then word_break($width) | join("\n") end;
def lb: if $width > 0 then _word_break($width) | join("\n") end;
def _f($pln):
if type == "string" then gsub("\n"; " ")
elif .type == "document" then .children[] | _f("\n\n")

View File

@ -20,8 +20,8 @@ Decode examples
Samples
=======
AVI has many redundant ways to index samples so currently .streams[].samples will only include samples the most "modern" way used in the file. That is in order
of stream super index, movi ix index then idx1 index.
AVI has many redundant ways to index samples so currently .streams[].samples will only include samples the most "modern" way used in
the file. That is in order of stream super index, movi ix index then idx1 index.
Extract samples for stream 1
============================

View File

@ -20,11 +20,12 @@ Decode examples
# Decode value as xml
... | xml({array:false,attribute_prefix:"@",seq:false})
XML can be decoded and encoded into jq values in two ways, elements as object or array. Which variant to use depends a bit what you want to do. The object variant
might be easier to query for a specific value but array might be easier to use to generate xml or to query after all elements of some kind etc.
XML can be decoded and encoded into jq values in two ways, elements as object or array. Which variant to use depends a bit what you
want to do. The object variant might be easier to query for a specific value but array might be easier to use to generate xml or to
query after all elements of some kind etc.
Encoding is done using the toxml function and it will figure what variant that is used based on the input value. Is has two optional options indent and
attribute_prefix.
Encoding is done using the toxml function and it will figure what variant that is used based on the input value. Is has two optional
options indent and attribute_prefix.
Elements as object
==================
@ -36,7 +37,8 @@ Element can have different shapes depending on body text, attributes and childre
- <a><b/><b>text</b></a> is {"a":{"b":["","text"]}} two children with same name end up in an array
- <a><b/><b key="value">text</b></a> is {"a":{"b":["",{"#text":"text","@key":"value"}]}}
If there is #seq attribute it encodes the child element order. Use -o seq=true to include sequence number when decoding, otherwise order might be lost.
If there is #seq attribute it encodes the child element order. Use -o seq=true to include sequence number when decoding, otherwise
order might be lost.
# decode as object is the default