Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markoff cannot open files in the "Plain Text" format #4

Closed
sharplet opened this issue Feb 29, 2016 · 15 comments
Closed

Markoff cannot open files in the "Plain Text" format #4

sharplet opened this issue Feb 29, 2016 · 15 comments

Comments

@sharplet
Copy link

To be honest, I just find this kind of amusing!

capture 2016-03-01 at 10 47 14 am

¯_(ツ)_/¯

Any files with the extension .txt are greyed-out in the file chooser, and I got this error using open -a Markoff foo.txt.

@balthisar
Copy link

+1, would be good fix.

@balthisar
Copy link

Quick fix is in #20 and will allow attempting to open any arbitrary filetype.

@kaishin
Copy link
Owner

kaishin commented Mar 7, 2016

@sharplet What would you expect when opening a .txt file? Be treated as if it was a Markdown file?

@sharplet
Copy link
Author

sharplet commented Mar 7, 2016

Yes, more or less. I find it doesn't matter if it's not actually a markdown file and produces strange markup. It's helpful to have the flexibility to preview any plain text file.

@balthisar
Copy link

Lots of markdown files have other extensions, e.g., chained through other processors. For example my file.html.md.erb is a typical static site generator markdown file.

@kaishin
Copy link
Owner

kaishin commented Mar 7, 2016

@balthisar I have concerns about allowing any extension though. Will force us to handle errors and whatnot and it's not user-friendly when all files can be opened but only few will yield results.

@balthisar
Copy link

I could help take a look at this. As-is if I (for example) try to drag an image while allowing any file, it shows an appropriate warning (unable to parse the file).

To be more fancy you could tweak the CFBundleDocumentTypes entry to allow other extensions (pretty much any text extension might be acceptable; plain text is valid markdown for the most part).

I notice right now the existing entry uses CFBundleTypeOSTypes which is, while not officially deprecated, not all that useful for modern text files, especially in that it's allowing ????. Types and creators have been deprecated since 10.6 and are no longer even considered on the current deployment target.

The "modern" replacement is LSItemContentTypes which uses UTI's instead of type-creator codes.

Then it's a decision on which UTI's to support. Using public.txt should be almost automatic. There's still the problem of the markdown engine trying to parse non-markdown, but again, that's not a bad thing. Most plain text will render just fine. Some of the other system defined UTIs might be candidates, too.

John Gruber has even indicated a preferred UTI for Markdown (UTIs aren't limited to Apple's system UTIs).

net.daringfireball.markdown, which conforms to public.plain-text. The encoding should always be UTF-8.

So there's good support for arguing public.plain-text in addition to public.txt that I mentioned.

@vcavallo
Copy link

vcavallo commented Mar 7, 2016

+1 The files in which I use markdown syntax are often .txt. For my (and I imagine many people's) workflows it makes the most sense to keep plain text in txt format and then let the context in which it's being used dictate how it should be rendered. (now I'm wondering why I use any extension at all...)
The whole advantage of markdown is that I can use its syntax in non-fancy plain text files without any special handling and the syntax itself communicates the markup's intention - the markdown processors I look at them with are just a luxury.

@nickdunn
Copy link

I also hit this problem when trying to open Markdown files from Jekyll that I save as .md.erb because I process some dynamic snippets within the file.

@vcavallo
Copy link

@nickdunn Have you opened up those .md.erb files in any other markdown previewer? Like Mou or something?

@nickdunn
Copy link

Yes, fine in Mou. They are just markdown (with a tiny bit of embedded ruby) but saved as .erb so Markoff doesn't recognise them.

@vcavallo
Copy link

How do the Ruby code and erb tags look in the markdown? Like like plain
text? I don't have any similar files handy to look at myself but I'd assume
there would be some weirdness with the erb code not being fenced or
back-ticked and the characters being used by the markdown processor
erroneously.
On Fri, Mar 11, 2016 at 9:49 AM Nick Dunn notifications@github.com wrote:

Yes, they are just markdown (with a tiny bit of embedded ruby) but saved
as .erb.


Reply to this email directly or view it on GitHub
#4 (comment).

Vinney Cavallo http://vinneycavallo.com/

@nickdunn
Copy link

Something simple like:

Here is a paragraph.

<% code('js') do %>
var expect = chai.expect;
<% end %>

Here is another paragraph.

Markoff renders the ERB as plain text as expected in this example. I'm not expecting Markoff to deal with this gracefully, but I'd like to be able to view the file as-is while editing the plain text parts.

@vcavallo
Copy link

I absolutely agree. Sorry for the tangent :)

On Fri, Mar 11, 2016 at 9:55 AM Nick Dunn notifications@github.com wrote:

Something simply like:

Here is a paragraph.

<% code('js') do %>
Here is some JavaScript
<% end %>

Here is another paragraph.

Markoff renders the ERB as plain text as expected in this example. I'm not
expecting Markoff to deal with this gracefully, but I'd like to be able to
view the file as-is while editing the plain text parts.


Reply to this email directly or view it on GitHub
#4 (comment).

Vinney Cavallo http://vinneycavallo.com/

kaishin pushed a commit that referenced this issue Mar 31, 2016
- Using LSItemContentTypes instead of CFBundleTypeOSTypes
- Closes #4
@kaishin kaishin mentioned this issue Mar 31, 2016
@vcavallo
Copy link

vcavallo commented Apr 1, 2016

:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants