**Monday Mini-Golf:** A series of short [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") challenges, posted (hopefully!) every Monday.

Many web applications (especially social media) automatically truncate long passages of text so they fit within the app's formatting. In this challenge, we're going to create an algorithm to automatically trim a passage of text to a certain length.

Challenge
=========

The goal of the challenge is to write a program or function that takes in two arguments:

* *T*, the text to truncate.
* *L*, the maximum length to return.

And returns *T*, truncated with the following logic:

* If the length of *T* is less than or equal to *L*, no truncation is needed. Return the original string.
* Truncate *T* to length *L*-2. If this contains no spaces or hyphens, return *T* truncated to exactly *L*-3 characters, followed by an ellipsis `...`.
* Otherwise, trim the end of the result up to the last space or hyphen. Add an ellipsis `...` and return the result.

Details
=======

* *T* and *L* may be taken in either order and any format.
* You may assume that 3 < *L* < 231.
* You may not use U+2026 Horizontal Ellipsis `…`; you must use three periods.
* The input will not start with a space or a hyphen.
* The input will not contain any whitespace other than regular spaces. (No tabs, newlines, etc.)

Test-cases
==========

### Inputs:

```
"This is some very long text." 25
"This-is-some-long-hyphen-separated-text." 33
"Programming Puzzles & Code Golf is a question and answer site for programming puzzle enthusiasts and code golfers." 55 
"abcdefghijklmnopqrstuvwxyz" 20
"a b c" 4
"Very long." 100

```

### Outputs:

```
"This is some very long..."
"This-is-some-long-hyphen..."
"Programming Puzzles & Code Golf is a question and..."
"abcdefghijklmnopq..."
"a..."
"Very long."

```

(Note that the quotes are just to specify that these are strings; they need not be included.)

Scoring
=======

This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest valid code in bytes wins. Tiebreaker goes to submission that reached its final byte count first. ~~The winner will be chosen next Monday, Oct 5. Good luck!~~

**Edit:** Congrats to your winner, @Jakube with Pyth again, with **25 bytes!**