diff --git a/lib/notational-velocity-view.coffee b/lib/notational-velocity-view.coffee index 67c2b33..7625a7d 100644 --- a/lib/notational-velocity-view.coffee +++ b/lib/notational-velocity-view.coffee @@ -1,4 +1,5 @@ path = require 'path' +fs = require 'fs' {$, $$, SelectListView} = require 'atom' module.exports = @@ -7,21 +8,36 @@ class NotationalVelocityView extends SelectListView console.log 'initialize' super - @addClass('from-top overlay') - @data = [ - { - 'title': 'car', - 'content': 'Car: A car is a wheeled, self-powered motor vehicle used for transportation. Most definitions of the term specify that cars are designed to run primarily on roads, to have seating for one to eight people, to typically have four wheels, and to be constructed principally for the transport of people rather than goods.' - }, - { - 'title': 'bar', - 'content': 'Bar: Bars provide stools or chairs that are placed at tables or counters for their patrons. Some bars have entertainment on a stage, such as a live band, comedians, go-go dancers, or strippers. Bars which offer entertainment or live music are often referred to as music bars or nightclubs.' + @addClass('notational-velocity from-top overlay') + @loadData() + + loadData: -> + @data = [] + + # TODO: remove this temporary hard-coded path + directory = '/Users/seongjae/github/notational-velocity/testdata' + + for filename in fs.readdirSync(directory) + filepath = path.join(directory, filename) + filetext = fs.readFileSync(filepath, 'utf8') + + title = '' + result = filetext.match(/^#\s.+/) + if result != null + title = result[0].slice(2, result[0].length) + + item = { + 'title': title, + 'filetext': filetext, + 'filename': filename, + 'filepath': filepath } - ] + @data.push(item) + @setItems(@data) getFilterKey: -> - 'content' + 'filetext' toggle: -> console.log 'toggle' @@ -33,12 +49,17 @@ class NotationalVelocityView extends SelectListView viewForItem: (item) -> console.log 'viewForItem #{item}' - element = document.createElement('li') - element.textContent = item.content - element + index = item.filetext.search /\n/ + content = item.filetext.slice(index, item.filetext.length) + + $$ -> + @li class: 'two-lines', => + @div "#{item.title}", class: 'primary-line' + @div "#{content}", class: 'secondary-line' confirmed: (item) -> console.log 'confirmed #{item}' + atom.workspaceView.open(item.filepath) destroy: -> console.log 'destroy' @@ -66,3 +87,9 @@ class NotationalVelocityView extends SelectListView populateList: -> console.log 'populateList' super + + selectItemView: (view) -> + console.log 'selectItemView' + super(view) + return unless view.length + console.log @list.indexOf(@list.find('.selected')) diff --git a/package.json b/package.json index 085fbc4..e4d2664 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,6 @@ "atom": ">0.50.0" }, "dependencies": { - "fs-plus": "2.x", + "fs-plus": "2.x" } } diff --git a/stylesheets/notational-velocity.less b/stylesheets/notational-velocity.less index c7cfa1a..9549968 100644 --- a/stylesheets/notational-velocity.less +++ b/stylesheets/notational-velocity.less @@ -5,4 +5,8 @@ @import "ui-variables"; .notational-velocity { + li { + text-overflow: ellipsis; + overflow-x: hidden; + } } diff --git a/testdata/car.md b/testdata/car.md new file mode 100644 index 0000000..f0345c7 --- /dev/null +++ b/testdata/car.md @@ -0,0 +1,5 @@ +# Car + +A car is a wheeled, self-powered motor vehicle used for transportation. Most definitions of the term specify that cars are designed to run primarily on roads, to have seating for one to eight people, to typically have four wheels, and to be constructed principally for the transport of people rather than goods.The year 1886 is regarded as the birth year of the modern car. In that year, German inventor Karl Benz built the Benz Patent-Motorwagen. Cars did not become widely available until the early 20th century. One of the first cars that was accessible to the masses was the 1908 Model T, an American car manufactured by the Ford Motor Company. Cars were rapidly adopted in the United States of America, where they replaced animal-drawn carriages and carts, but took much longer to be accepted in Western Europe and other less-developed parts of the world. + +Cars are equipped with controls used for driving, parking, and passenger comfort and safety. New controls have also been added to vehicles, making them more complex. Examples include air conditioning, navigation systems, and in car entertainment. Most cars in use today are propelled by an internal combustion engine, fueled by deflagration of gasoline (also known as petrol) or diesel. Both fuels are known to cause air pollution and are also blamed for contributing to climate change and global warming. Vehicles using alternative fuels such as ethanol flexible-fuel vehicles and natural gas vehicles are also gaining popularity in some countries. diff --git a/testdata/commonmark.md b/testdata/commonmark.md new file mode 100644 index 0000000..52c8bec --- /dev/null +++ b/testdata/commonmark.md @@ -0,0 +1,32 @@ +# CommonMark + +## Why is a spec needed? + +John Gruber’s canonical description of Markdown’s syntax does not specify the syntax unambiguously. + +In the absence of a spec, early implementers consulted the original `Markdown.pl` code to resolve these ambiguities. But `Markdown.pl` was quite buggy, and gave manifestly bad results in many cases, so it was not a satisfactory replacement for a spec. + +Because there is no unambiguous spec, implementations have diverged considerably. As a result, users are often surprised to find that a document that renders one way on one system (say, a GitHub wiki) renders differently on another (say, converting to docbook using Pandoc). To make matters worse, because nothing in Markdown counts as a “syntax error,” the divergence often isn't discovered right away. + +There's no standard test suite for Markdown; [the unofficial MDTest](https://github.com/michelf/mdtest/) is the closest thing we have. The only way to resolve Markdown ambiguities and inconsistencies is [Babelmark](http://johnmacfarlane.net/babelmark2/), which compares the output of 20+ implementations of Markdown against each other to see if a consensus emerges. + +We propose a standard, unambiguous syntax specification for Markdown, along with a suite of comprehensive tests to validate Markdown implementations against this specification. We believe this is necessary, even essential, for the future of Markdown. + +That's what we call CommonMark. + +## Who are you? + +We're a group of Markdown fans who either work at companies with industrial scale deployments of Markdown, have written Markdown parsers, have extensive experience supporting Markdown with end users – or all of the above. + +- John MacFarlane, jgm@berkeley.edu +- David Greenspan, david@meteor.com +- Vicent Marti, vicent@github.com +- Neil Williams, neil@reddit.com +- Benjamin Dumke-von der Ehe, ben@stackexchange.com +- Jeff Atwood, jatwood@codinghorror.com + +# When is the spec final? + +The current version of the CommonMark spec is complete (two years in the making!), but provisional pending public feedback, testing, and evaluation. + +With your help, we plan to announce a finalized 1.0 spec and test suite in the next few months, along with implementations in many different languages. diff --git a/testdata/evernote.md b/testdata/evernote.md new file mode 100644 index 0000000..b1201a6 --- /dev/null +++ b/testdata/evernote.md @@ -0,0 +1,3 @@ +# Evernote + +Evernote is a suite of software and services, designed for notetaking and archiving. A "note" can be a piece of formatted text, a full webpage or webpage excerpt, a photograph, a voice memo, or a handwritten "ink" note. Notes can also have file attachments. Notes can be sorted into folders, then tagged, annotated, edited, given comments, searched and exported as part of a notebook. diff --git a/testdata/github_flavored_markdown.md b/testdata/github_flavored_markdown.md new file mode 100644 index 0000000..16945a4 --- /dev/null +++ b/testdata/github_flavored_markdown.md @@ -0,0 +1,3 @@ +# Github Flavored Markdown + +GitHub uses "GitHub Flavored Markdown," or GFM, across the site--in issues, comments, and pull requests. It differs from standard Markdown (SM) in a few significant ways, and adds some additional functionality. diff --git a/testdata/markdown.md b/testdata/markdown.md new file mode 100644 index 0000000..85792d4 --- /dev/null +++ b/testdata/markdown.md @@ -0,0 +1,25 @@ +# Markdown + +Markdown is a text-to-HTML conversion tool for web writers. Markdown allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML). + +Thus, “Markdown” is two things: (1) a plain text formatting syntax; and (2) a software tool, written in Perl, that converts the plain text formatting to HTML. See the Syntax page for details pertaining to Markdown’s formatting syntax. You can try it out, right now, using the online Dingus. + +The overriding design goal for Markdown’s formatting syntax is to make it as readable as possible. The idea is that a Markdown-formatted document should be publishable as-is, as plain text, without looking like it’s been marked up with tags or formatting instructions. While Markdown’s syntax has been influenced by several existing text-to-HTML filters, the single biggest source of inspiration for Markdown’s syntax is the format of plain text email. + +## Getting the Gist of Markdown's Formatting Syntax + +This page offers a brief overview of what it’s like to use Markdown. The syntax page provides complete, detailed documentation for every feature, but Markdown should be very easy to pick up simply by looking at a few examples of it in action. The examples on this page are written in a before/after style, showing example syntax and the HTML output produced by Markdown. + +It’s also helpful to simply try Markdown out; the Dingus is a web application that allows you type your own Markdown-formatted text and translate it to XHTML. + +## History + +John Gruber, with substantial contributions from Aaron Swartz, created the Markdown language in 2004 with the goal of enabling people "to write using an easy-to-read, easy-to-write plain text format, and optionally convert it to structurally valid XHTML (or HTML)”. + +Taking cues from existing conventions for marking up plain text in email, such as setext, the language was designed to be readable as-is, without looking like it's been marked up with tags or formatting instructions, unlike text formatted with a markup language, such as Rich Text Format (RTF) or HTML, which have obvious tags and formatting instructions. + +## Standardization + +There is no clearly defined Markdown standard, apart from the original writeup and implementation by John Gruber, which some consider to be abandonware. This has led to fragmentation as different vendors write their own variants of the language to correct flaws or add missing features. + +From 2012 through 2014, a group of people including Jeff Atwood launched what Atwood characterized as a standardization effort. A community website now aims to "document various tools and resources available to document authors and developers, as well as implementors of the various markdown implementations". In September 2014, Gruber objected to the usage of "Markdown" in the name of this effort and it was rebranded as a new dialect named "CommonMark". diff --git a/testdata/multimarkdown.md b/testdata/multimarkdown.md new file mode 100644 index 0000000..7b1e8de --- /dev/null +++ b/testdata/multimarkdown.md @@ -0,0 +1,29 @@ +# MultiMarkdown + +> “As the world goes multi-platform with all of the new mobile operating systems, MultiMarkdown provides an easy way to share formatting between all of my devices. It’s easy to learn (even for us mortals) and immediately useful.” +> +> \- David Sparks, [MacSparky.com](http://macsparky.com) + +> “Personally, it’s changed my game — it’s how I think now. Can’t imagine writing more than a paragraph in anything that doesn’t do MMD.” +> +> \- Merlin Mann, kung fu grippe + +## What is MultiMarkdown? + +MultiMarkdown, or MMD, is a tool to help turn minimally marked-up plain text into well formatted documents, including HTML, PDF (by way of LaTeX), OPML, or OpenDocument (specifically, Flat OpenDocument or ‘.fodt’, which can in turn be converted into RTF, Microsoft Word, or virtually any other word-processing format). + +MMD is a superset of the Markdown syntax, originally created by John Gruber. It adds multiple syntax features (tables, footnotes, and citations, to name a few), in addition to the various output formats listed above (Markdown only creates HTML). Additionally, it builds in “smart” typography for various languages (proper left- and right-sided quotes, for example). + +MultiMarkdown started as a Perl script, which was modified from the original Markdown.pl. + +MultiMarkdown v3 (aka ‘peg-multimarkdown’) was based on John MacFarlane’s peg-markdown. It used a parsing expression grammar (PEG), and was written in C in order to compile on almost any operating system. Thanks to work by Daniel Jalkut, MMD v3 was built so that it didn’t have any external library requirements. + +MultiMarkdown v4 is basically a complete rewrite of v3. It uses the same basic PEG for parsing (Multi)Markdown text, but otherwise is almost completely rebuilt: + +- The code is designed to be easier to maintain — it’s divided into separate files on a more logical structure +- All memory leaks (to my knowledge) have been fixed +- [greg] is used instead of [peg/leg] to create the parser — this allows the parser to be thread-safe +- The [test suite] has been modified to account for several improvements. MMD should fail one of the basic Markdown tests (see peg-markdown for more information). Currently it fails one of the LaTeX tests — this is not intentional and I am working on a fix. +- Command line options are slightly different. + +For another description of what MultiMarkdown is, you can also check out a PDF slide show that describes and demonstrates how MultiMarkdown can be used. diff --git a/testdata/notational_velocity.md b/testdata/notational_velocity.md new file mode 100644 index 0000000..549a821 --- /dev/null +++ b/testdata/notational_velocity.md @@ -0,0 +1,14 @@ +# Notational Velocity + +NOTATIONAL VELOCITY is an application that stores and retrieves notes. + +It is an attempt to loosen the mental blockages to recording information and to scrape away the tartar of convention that handicaps its retrieval. The solution is by nature nonconformist. + +## Unique Characteristics + +- __Modeless Operation__: Searching for notes is not a separate action; rather, it is the primary interface. +- __Incremental Search__: Searching encompasses all notes' content and occurs instantly with each key pressed. +- __Transparent Database Encryption__: All content is compressed and encrypted (enabled optionally) before it is recorded to disk. +- __Mouseless Interaction__: Notational Velocity's window was designed for keyboard input above all else, and thus has no buttons. +- __Data Instead of Documents__: There is no manual "saving" in Notational Velocity; all modifications take effect immediately. +- __Complete External Access__: Synchronize natively with Simplenote, or via files in Dropbox with PlainText, Elements, iA Writer, and other iOS apps. diff --git a/testdata/nvalt.md b/testdata/nvalt.md new file mode 100644 index 0000000..5d4790d --- /dev/null +++ b/testdata/nvalt.md @@ -0,0 +1,22 @@ +# nvALT + +## What it is + +Notational Velocity is a way to take notes quickly and effortlessly using just your keyboard. You press a shortcut to bring up the window and just start typing. It will begin searching existing notes, filtering them as you type. You can use ⌘-J and ⌘-K to move through the list. Enter selects and begins editing. If you’re creating a new note, you just type a unique title and press enter to move the cursor into a blank edit area. Check out the descriptions at notational.net for a more eloquent synopsis. + +## Notational Velocity Features + +- Option for horizontal layout with multi-line previews in notes list +- Words between [[double-brackets]] will become links to other notes +- Tags are synced to Dropbox and searched by Spotlight, via OpenMeta +- Tags are auto-completed while typing in the tag-entry field +- TaskPaper-compatible strikethrough formatting using the “@done” tag +- Fully plain-text-based automatic list-bullet formatting +- Note-titles inside double-brackets are (optionally) auto-completed +- “Show in Finder” command for revealing selected note-files on disk +- Highlighting of search terms can be disabled +- Dragging the divider to the top or left of the window will hide search field +- and more http://notational.net/releasenotes/release2/ +- Open in external text editor + +## nvALT Additional Features diff --git a/testdata/united_states.md b/testdata/united_states.md new file mode 100644 index 0000000..ffd06dc --- /dev/null +++ b/testdata/united_states.md @@ -0,0 +1,3 @@ +# United States + +The United States of America (USA or U.S.A.), commonly referred to as the United States (US or U.S.), America, and sometimes the States, is a federal republic consisting of 50 states and a federal district. The 48 contiguous states and Washington, D.C., are in central North America between Canada and Mexico. The state of Alaska is the northwestern part of North America and the state of Hawaii is an archipelago in the mid-Pacific. The country also has five populated and nine unpopulated territories in the Pacific and the Caribbean. At 3.80 million square miles (9.85 million km2) and with around 318 million people, the United States is the world's third- or fourth-largest country by total area and third-largest by population. It is one of the world's most ethnically diverse and multicultural nations, the product of large-scale immigration from many countries. The geography and climate of the United States is also extremely diverse, and it is home to a wide variety of wildlife.