{"id":15017749,"url":"https://github.com/trantor/ics-line-unfolder","last_synced_at":"2026-02-25T21:32:06.534Z","repository":{"id":148827692,"uuid":"192008063","full_name":"trantor/ics-line-unfolder","owner":"trantor","description":"Code to unfold folded lines in iCalendar/ics files","archived":false,"fork":false,"pushed_at":"2019-06-16T18:34:48.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-11-10T13:31:56.372Z","etag":null,"topics":["ical","icalendar","ics","one-liner","perl","perl-script","perl5","regex","unfolding"],"latest_commit_sha":null,"homepage":null,"language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trantor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-14T21:33:56.000Z","updated_at":"2019-06-16T18:34:50.000Z","dependencies_parsed_at":"2023-06-27T19:00:49.765Z","dependency_job_id":null,"html_url":"https://github.com/trantor/ics-line-unfolder","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/trantor/ics-line-unfolder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trantor%2Fics-line-unfolder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trantor%2Fics-line-unfolder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trantor%2Fics-line-unfolder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trantor%2Fics-line-unfolder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trantor","download_url":"https://codeload.github.com/trantor/ics-line-unfolder/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trantor%2Fics-line-unfolder/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29841591,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T21:18:31.832Z","status":"ssl_error","status_checked_at":"2026-02-25T21:18:29.265Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ical","icalendar","ics","one-liner","perl","perl-script","perl5","regex","unfolding"],"created_at":"2024-09-24T19:50:56.218Z","updated_at":"2026-02-25T21:32:06.517Z","avatar_url":"https://github.com/trantor.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ics-line-unfolder\n## Description\nFor iCalendar files RFC 5545 advises at [section 3.1](https://tools.ietf.org/html/rfc5545#section-3.1):\n\u003e The iCalendar object is organized into individual lines of text, called content lines. Content lines are delimited by a line break, which is a CRLF sequence (CR character followed by LF character).\n\u003e \n\u003eLines of text SHOULD NOT be longer than 75 octets, excluding the line break. Long content lines SHOULD be split into a multiple line representations using a line \"folding\" technique. That is, a long line can be split between any two characters by inserting a CRLF immediately followed by a single linear white-space character (i.e., SPACE or HTAB). Any sequence of CRLF followed immediately by a single linear white-space character is ignored (i.e., removed) when processing the content type.\n\nTherefore iCalendar files usually fold content lines containing text whose encoded form is longer than 75 octets.\nThat makes them quite inconvenient to process using line-oriented tools/code, for instance to replace portions of those lines using `sed` or to match patterns against those lines using `grep` or similar tools.\n\nThe purpose of this code is to process iCalendar files creating files with identical content lines, this time unfolded.\nAs a corollary lines _could_ be longer than 75 octets + linebreak. In deference to the section of the RFC quoted above, the output lines are terminated by a CRLF 2-character sequence (CarriageReturn LineBreak, or \\r\\n for anyone familiar with this notation).\n## Details and usage\n### Line-processing version\nThe code is written in Perl 5, reading line by line with a sliding window allowing to concatenate the continuation lines to the starting line.\n#### Usage\n```\nperl ics_line_unfolder.pl SOURCE.ics \u003e OUTPUT.ics\n\nor\n\n\u003c SOURCE.ics perl ics_line_unfolder \u003e OUTPUT.ics\nif you wish to read the source ics file from the standard input\n```\n#### Alternative one-liner\nA very concise one-liner which should perform exactly as programme in the file follows. Useful for a quick copy-and-paste in a shell pipeline. In order to maximise its compactness it will likely appear quite cryptic.\n```\n# for Perl 5.10+\nPERLIO=:crlf perl -C -wnE 'state$a;$a//($a=$_,next);s///,substr($a,(length$a)-1)=$_,(eof(ARGV)and print$a),next if /^[\\t ]/;print $a;$a=$_;$a=undef,print if eof(ARGV);'\n```\nSee the examples for the regex-based one-liners below for a practical, if trivial, usage scenario.\n### Regex-based version\nThe code is written in Perl 5, using a substitution with code embedded in the regex to perform the actual line unfolding.\nSee the comments in the programme for further details.\nSince it reads the entire contents of the file it could be quite memory-hungry.\nGiven how it performs no syntax validation, just simple unfolding, it offers no practical advantage to the other version and has a potentially significative memory footprint downside, so it's more of an exercise in regex use.\n#### Usage\n```\nperl ics_line_unfolder_regex.pl SOURCE.ics \u003e OUTPUT.ics\n\nor\n\n\u003c SOURCE.ics perl ics_line_unfolder_regex.pl \u003e OUTPUT.ics\nif you wish to read the source ics file from the standard input\n```\n#### Alternative one-liner\nA very concise one-liner which should perform exactly as programme in the file follows. Useful for a quick copy-and-paste in a shell pipeline. In order to maximise its compactness it will likely appear quite cryptic.\n```\nPERLIO=:crlf perl -0777 -C -pe 'my$g;s/^(?{local$v;})([^\\t ][^\\n]*+)(?:\\n[\\t ]([^\\n]*)(?{substr($v,length$v)=$^N}))++(?{$g=$v})/$1$g/mg'\n#\n# or for Perl 5.12+ ( \\N equivalent to [^\\n] )\n#\nPERLIO=:crlf perl -0777 -C -pe 'my$g;s/^(?{local$v;})([^\\t ]\\N*+)(?:\\n[\\t ](\\N*)(?{substr($v,length$v)=$^N}))++(?{$g=$v})/$1$g/mg'\n\n# e.g.\n$ cat SOURCE.ics |\nPERLIO=:crlf perl -0777 -C -pe 'my$g;s/^(?{local$v;})([^\\t ][^\\n]*+)(?:\\n[\\t ]([^\\n]*)(?{substr($v,length$v)=$^N}))++(?{$g=$v})/$1$g/mg' |\nsed '/ORGANIZER/ s/mailto:address1@dom.tld/mailto:subst_address@dom.tld/' \u003e CONVERTED.ics\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrantor%2Fics-line-unfolder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrantor%2Fics-line-unfolder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrantor%2Fics-line-unfolder/lists"}