Auto bold, strikethrough etc. in blocked text


#1

Hello, I am blogger who makes posts with markdown in atom.
I could make words bold just with blocking and press ‘*’ button. (This method returns text blocked text)
And also, making strikethrough text was like bold. (Block text, which I want to make strikethrough, and just press ‘~’. and it returns “blocked text”)

However, today, it doesn’t work. I don’t know what I modify settings. Below things are in my packages.

  • language-gfm-enhanced
  • markdown-preview-enhanced
  • markdown-writer
  • language-markdown

Could you make my markdown editor easier, please?


#2

Please tell us precisely what is not working.


#4

I can’t use the function which I mentioned. I cannot use convenient function that returns **blocked text** or blocked text Sorry for lack of English @_@


#5

I don’t know what function you’re talking about. What keybinding do you expect to give you the formatted text?


#7

Well. Sorry about my explain ability :frowning:

Please see below order.

– the day when I use this well –

  1. Open .md file in atom
  2. Write some articles.
  3. “Oh I want to make this text to bold text”
  4. Block(Drag) these text
  5. press ‘*’ on the keyboard
  6. It becomes text

– Nowadays –

  1. Open .md file in atom
  2. Write some articles
  3. “Oh I want to make this text to bold text”
  4. Block(Drag) these text
  5. press ‘*’ on the keyboard
  6. It becomes just *
  7. What the hell on my atom editor! why it doesn’t work!!!

??? Why this isn’t work!!
(Strikethrough (text) is same)


#8

Oops, I am not familiar with this discussion editor.

Correction: – the day when I use this well –
6. I becomes **text**


#9

I looked at those packages and it doesn’t seem like any of them do what you want them to do. However, you can write a command that does this. Put the following code into your init.coffee file:

wrapSelection = (before, after) ->
  selections = atom.workspace.getActiveTextEditor().getSelections()

  for selection in selections
    selectedText = selection.getText()
    if selection.isEmpty()
      selection.insertText("#{before}#{selectedText}")
    else
      selection.insertText("#{before}#{selectedText}#{after}")

atom.commands.add 'atom-text-editor', 'custom:wrap-bold', ->
  tag = '*'
  
  wrapSelection(tag, tag)

atom.commands.add 'atom-text-editor', 'custom:wrap-strikethrough', ->
  tag = '~'
  
  wrapSelection(tag, tag)

In your keymap.cson:

'atom-text-editor':
  '*': 'custom:wrap-bold'
  '~': 'custom:wrap-strikethrough'

Reload Atom and you’ll have the command available. You can replicate this by simply copying the atom.commands.add call and changing the name and tag.


#10

Thank you, I will try this after work :slight_smile:


#11

I found this option on my atom. I think that this is the problem. Why doesn’t this work properly? Do you have any idea about this?


#12

I don’t know why it doesn’t work. @burodepeper might be better able to help you with troubleshooting.


#13

Thank you for replying my question with kindness! :slight_smile:


#14

Hey there @TyeolRik,

I’m the author of language-markdown. I notice that you also have language-gfm-enhanced installed. Your Atom might have ‘chosen’ this package to show you Markdown files, and in doing so you can’t use language-markdown's options at the same time. Could you try disabling language-gfm-enhanced and reloading Atom to see if that helps?


#15

I am really sorry to late reply. (Recently I have a hard time to do my job, and forgot this page LUL sorry)

Actually, I can use that function by setting language “Markdown” not “GitHub Markdown”.

Thank you for the answers and I wish you to have a great 2017 LUL