Programatically create a new file field

Been looking around the docs and cant find anything about new Field - can someone please point me in the right direction?

Or tell me i’m barking up the wrong tree… i’m trying to turn a chunk of text into kirbytext and for that I need to put it in a field programmatically i think. I’ve tried this but it isn’t happy… can this be done in a file method? The text is song lyrics so its multi line and can be quite long, so i want to turn into html.

Ive fetched the lyrics from the ID tag of a mp3 file, but thats not important, its a string and i need it in a field i think in order to run kt() on it.

$lyricraw = $mediaid['comments_html']['unsynchronised_lyric'];
$lyricclean = implode('', $lyricraw);
$lyric = new Field($this, null, $lyricclean);

The new Field constructor doesn’t like null as second argument, use an empty string instead.

$lyric = new Field($this, '', $lyricclean);

That worked great - with one small problem. When i run it though kt() it seems to wrap the whole lot in P tags, rather then the individual paragraphs. Its like its not seeing it as markdown or maybe there arn’t any paragraph/line breaks for it to see.

hmmm… wonder how to sort that.

Sounds like this could be the Problem. Are they actually included in $lyricraw?

I did investigate a little bit and as far as i could tell, the paragraph and line breaks are there in the actual ID tag on the MP3 file (I checked this with a tag editor).

It seems like this gets stripped when it gets put in a string in the array, only spaces come through. Got no idea how to solve it.