Page 1 of 6 123 ... LastLast
Results 1 to 10 of 57

Thread: How to restore broken lines in links in my PHP editor?

  1. #1
    Join Date
    Oct 2012
    Posts
    180
    Thanks
    22
    Thanked 1 Time in 1 Post

    Default How to restore broken lines in links in my PHP editor?

    What happens is the broken lines in links do not show correctly in my markdown editor. For instance the editor will not render
    Code:
     border="0"
    in this instance:

    Code:
    <a href="http://somedomain.com" rel="nofollow">
    
    <img src="http://somedomain.com/images/someimage.png"
    border="0"></a><br>
    I need it to be on the same line as the rest of the link like this:

    Code:
    <a href="http://somedomain.com" rel="nofollow">
    
    <img src="http://somedomain.com/images/someimage.png" border="0"></a><br>
    Which php command can accomplish this?

    Thanks!
    Last edited by traq; 01-10-2013 at 02:51 AM.

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Your question is unclear.
    Please provide more information, and be as specific as possible.
    • What do you want to accomplish?
    • What have you already tried?
    • What problems did you encounter?

    Also, please be sure that you have included all relevant code and/or a link to the page in question.
    You might also consider making a reduced test case using an online tool like jsfiddle.


    What "markdown editor"?
    "Markdown" is a text parser. Some WYSIWYG editors use markdown; if that's what you're talking about, please specify which editor you're using. Furthermore, you don't show any Markdown usage in your examples.

    (Also, your title refers to a "PHP Editor", which -to me- implies a code editor or IDE, and seems entirely unrelated to what you talk about in the body of the thread.)

    What do you mean by "broken lines"?
    You seem to use "broken lines" to refer both to the border around the image, and to literal line breaks in your HTML markup (and, possibly, to the dotted outline normally displayed around hyperlinks). However, what you say below makes me suspect you don't really mean any of these.

    What do you mean by "will not render"?
    Both the examples you give are HTML markup, and are functionally equal. They will be rendered identically in any browser.

    What "PHP"?
    There is no PHP code in your examples. Are you referring to the Markdown parser itself?

    ---------------

    If all you want to accomplish is this
    HTML Code:
    <a href="http://somedomain.com" rel="nofollow">
    
    <img src="http://somedomain.com/images/someimage.png" border="0"></a><br>
    as opposed to this
    HTML Code:
    <a href="http://somedomain.com" rel="nofollow">
    
    <img src="http://somedomain.com/images/someimage.png"
    border="0"></a><br>
    (which is not, as you seem to be implying, "on the same line as the rest of the link")

    Then just write it that way - no PHP, beyond, possibly, echo, is required.
    Last edited by traq; 12-19-2012 at 01:58 AM.

  3. #3
    Join Date
    Oct 2012
    Posts
    180
    Thanks
    22
    Thanked 1 Time in 1 Post

    Default

    Ok, I should have simply asked this. What php code should I use to get rid of new lines WITHIN a hyper link:

    Original code:

    Code:
    <img src="http://somedomain.com/images/someimage.png"
    border="0">
    I want it to be:

    Code:
    <img src="http://somedomain.com/images/someimage.png" border="0">
    Thanks!

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    "Hyperlinks" do not exist in PHP. Only text does. How is this text stored? Is it being generated by PHP? Is it on another page?

    Are you attempting to reformat or parse HTML using PHP?


    That's why traq's post asks for a lot of information. We can't understand how to answer without actually understanding what you're doing. On a technical level, it just doesn't make sense-- "hyperlinks" aren't in PHP, so you can't change them. You can probably indirectly accomplish that, but we'd need to know how you have set this up.



    Regardless, if you can get it as a string, then you can use str_replace() to change line breaks to an empty string ''. Or you can using some form of regular expressions (probably the preg_ family of functions) to search out only things in text that looks like a URL, or something along those lines.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Oct 2012
    Posts
    180
    Thanks
    22
    Thanked 1 Time in 1 Post

    Default

    Of course it is done with preg_replace. The question is how?

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    I have no idea. Your questions/explanations aren't enough for us to help you with this.

    You can look up a regex tutorial online and see the PHP.net manual for preg_replace.

    Do you already have it as a string?

    What exactly are the conditions (in terms understandable to a computer, not "hyperlinks") that would make this occur? [This will be your regex environment]

    What do you want to replace in that environment? Just line breaks? [this will be added to your regex environment to make the "find" part]

    When do you want to replace it with? Always just delete it? You can use an empty string-- ''. [this will be your "replace" part]



    If you need more help, I imagine it will be with the regex for finding the environment. First, use google to see if someone has this code available (I'm sure there are at least some similar examples out there). Second, if you want our help with it, then be very precise about what is happening. Show us the "before" string (exactly as it exists in your PHP) and then what you want as the after string, including any variation that might come up.
    Last edited by traq; 12-20-2012 at 04:53 AM. Reason: added hyperlink to PHP manual
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  7. #7
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by qwikad.com View Post
    Of course it is done with preg_replace. The question is how?
    Please re-read my earlier post - once you provide all the information I asked about (particularly your actual code), we'll have a foundation for helping you figure out the rest.



    Please don't "simplify" the problem by leaving out contextual information/details that may be important. It is counter-productive.

    From reading both your thread title and your original post, I suspect that your problem involves more than just your hyperlinks. I'll bet it involves the Markdown parser, and also a WYSIWYG editor of some sort on your webpage (therefore, indirectly, whatever markdown you actually enter into it, not to mention the form submission itself).

  8. #8
    Join Date
    Oct 2012
    Posts
    180
    Thanks
    22
    Thanked 1 Time in 1 Post

    Default

    Here's a sample code from the file:

    Code:
    text = text.replace(/^[ \t]+$/mg,"");
    I need a code that would remove all new lines between < and > in HTML links.

    Thanks!

  9. #9
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by qwikad.com View Post
    Here's a sample code from the file:

    Code:
    text = text.replace(/^[ \t]+$/mg,"");
    I need a code that would remove all new lines between < and > in HTML links.

    Thanks!
    that's javascript code. Are we talking about javascript now?

  10. #10
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    I'm getting dizzy just reading this thread.

    Traq and Dan are trying to help you, but sadly, you are providing only very small, incomplete snippets of information, which is resulting in us making wild guesses.

    At the risk of further convoluting the thread with my own suggestions, maybe this will help? http://stackoverflow.com/questions/6...reaks-with-php
    Again, a total guess as to what you really need, but we are doing our best to offer assistance with the little direction you're giving us.

    To help things along, can you provide a small zip package of what you are trying to describe? Including your php/javascripts, along with the link to this php editor you speak of, would be most helpful. Or is there a developers site and demo - maybe even with online documentation or a forum - where you can direct us?

    We can appreciate how frustrated you might be - you need help, and it must seem like we're being finickity or awkward with the amount of information we're asking for, but it really is so we can pin-point your problem and offer you the most efficient and relevant answers. Please try to remember that you are very close to your own project, whereas we are just outsiders looking in, and we need to get our bearings, and a good feel for what is going on, before we can be of any real help to you.

    Until we have all the information upfront, we will be unable to give you any solid resolution. We're trying our best but everything to do with your project/problem is rather alien to us at the moment.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

Similar Threads

  1. How to create a broken links checker from scratch
    By SR123 in forum Looking for such a script or service
    Replies: 0
    Last Post: 06-03-2009, 03:03 PM
  2. Restore slide position!!!
    By shlajfka in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 11-25-2008, 01:04 PM
  3. links at the center appear broken
    By leonidassavvides in forum HTML
    Replies: 1
    Last Post: 04-23-2008, 02:49 PM
  4. Program to check broken links?
    By Freeman in forum The lounge
    Replies: 6
    Last Post: 08-24-2007, 04:04 PM
  5. Code Restore... (need help)
    By Harlem Of Nem in forum JavaScript
    Replies: 5
    Last Post: 08-06-2007, 08:03 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •